can someone help me debug the leaker errors on thios codeABS.H

#pragma once
#include <stdexcept>
#include <cstring>
#include <iostream>
using namespace std;
template <typename T>
class ABS {
private:
unsigned int capacity;
unsigned int count;
float scalerFactor = 2.0f;
T* array;
public:
ABS();
ABS(int capacity);
ABS(const ABS &d);
ABS&operator = (const ABS &d);
~ABS();
void push(T &data);
T pop();
T peek();
unsigned int getSize();
unsigned int getMaxCapacity() const;
T* getData();
const T &operator[] (unsigned int index) const;
T &operator[] (unsigned int index);
};
template<typename T>
inline ABS<T>::ABS(){
this->capacity = 1;
this->count = 0;
array = new T[capacity];
}
template<typename T>
inline ABS<T>::ABS(int capacity)
{
this->capacity = capacity;
this->count = 0;
array = new T[capacity];
}
template<typename T>
inline ABS<T>::ABS(const ABS & d)
{
this->count = d.count;
this->capacity = d.capacity;
this->array = new T[capacity];
for (unsigned int i = 0; i < capacity; i++) {
array[i] = d[i];
}
}
template<typename T>
ABS<T> & ABS<T>::operator=(const ABS & d){
if (this == &d) {
return *this;
}
if (array != nullptr) {
delete[] array;
}
this->count = d.count;
this->capacity = d.capacity;
this->array = new T[capacity];
for (unsigned int i = 0; i < capacity; i++) {
array[i] = d[i];
}
return this->*array;
}
template<typename T>
inline ABS<T>::~ABS() {
if (array != nullptr) {
delete[] array;
}
}
template<typename T>
void ABS<T>::push(T &data) {
if (count == capacity) {
this->capacity *= scalerFactor;
}
this->array[count] = data;
//cout << “array at count: ” << array[count]<< endl;
count++;
}
template<typename T>
inline T ABS<T>::pop() {
if (count == 0) {
//throw runtime_error(“Error!”);
return -1;
}
//cout << “count/cap: ” << ((float)count /(float)capacity) << endl;
if (count < 0.5*(float)capacity) {
capacity = capacity / scalerFactor;
}
T returnValue = array[count-1];
T* tempArray = new T[capacity];
for (unsigned int i = 0; i < count – 1; i++) {
//cout << “Int copied over: ” << array[i] <<endl;
tempArray[i] = array[i];
}
for (unsigned int i = count; i < capacity+1; i++) {
tempArray[i] = 0;
}
if (array != nullptr) {
delete[] array;
}
array = tempArray;
count–;
return returnValue;
/*if (count == 0) {
return -1;
}
if (count == capacity) {
capacity–;
}
T* tempArray = new T[capacity];
for (unsigned int i = 0; i < count; i++) {
this->array[i] = this->array[1];
}
count–;
if (array != nullptr) {
delete[] array;
}
this->array = tempArray;
return tempArray[count+1];*/
}
template<typename T>
inline T ABS<T>::peek()
{
if (capacity == 0) {
return -1;
}
else {
//cout << “element at the top of the stack” <<getData()[count-1] << endl;
return array[count-1];
}
}
template<typename T>
inline unsigned int ABS<T>::getSize()
{
return count;
}
template<typename T>
inline unsigned int ABS<T>::getMaxCapacity() const
{
return capacity;
}
template<typename T>
inline T * ABS<T>::getData()
{
return array;
}
template<typename T>
inline const T & ABS<T>::operator[](unsigned intindex) const
{
if (index > capacity || index < 0) {
//throw runtime_error(“Error! Invalid index”);
} else {
return array[index];
}
}
template<typename T>
inline T & ABS<T>::operator[](unsigned intindex)
{
if (index > capacity || index < 0) {
//throw runtime_error(“Error! Invalid index”);
}
else {
return array[index];
}
}

I am getting the below errors

LEAKER: unknown:unknown():0 checking error: wrote off end ofmemory allocated at unknown:unknown():0. *** Error in `./a.out’:free(): invalid next size (fast): 0x000000000092ec40 *** =======Backtrace: =========/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fd919e287e5]/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fd919e3137a]/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fd919e3553c]./a.out(_ZdaPv+0x64)[0x402fc0] ./a.out[0x401e7b] ./a.out[0x40124b]./a.out[0x40107b]/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fd919dd1830]./a.out[0x400f79]