Skip to content

Commit 5d5ca2c

Browse files
committed
realArray: fix arrayCount tracking and assignment size safety
1 parent 6ea51f6 commit 5d5ca2c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

source/source_base/realarray.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void realArray::freemem()
8484
{
8585
delete [] ptr;
8686
ptr = NULL;
87+
--arrayCount;
8788
}
8889

8990
void realArray::create(const int d1,const int d2,const int d3,const int d4)
@@ -126,6 +127,7 @@ void realArray::create(const int d1,const int d2,const int d3)
126127

127128
const realArray &realArray::operator=(const realArray &right)
128129
{
130+
assert(size == right.size); // Assignment only allowed for arrays of the same size
129131
for (int i = 0;i < size;i++) ptr[i] = right.ptr[i];
130132
return *this;// enables x = y = z;
131133
}

0 commit comments

Comments
 (0)