Mismatched delete / delete [] with 'array' new operator
The TS toolbox checkAvailableMemory(size_t availableMB)
function uses the standard delete
operator to deallocate storage that was allocated by a new[]
operator - i.e: (lines 174 - 180 of toolbox/src/common/Tools.cc
)
bool Tools::checkAvailableMemory ( size_t availableMB )
{
try
{
char* dummy = new char[availableMB * 1024 * 1024];
delete dummy;
}
Mixing new[]
with single-object delete
produces undefined behaviour according to the C++ standard; the deallocation here should be changed from delete dummy;
to delete[] dummy;
(This was spotted when running the SWATCH cell under valgrind)