mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-15 15:30:34 +05:00
Correct deletion of non-allocated memory in ngarray
A default-constructed (or just empty) ngarray will have 'ownmem' set despite not having an allocated data array. Destructor would then trigger an abort.
This commit is contained in:
parent
5ee4e43393
commit
6ba4a6e6c6
@ -295,6 +295,7 @@ namespace netgen
|
|||||||
/// if responsible, deletes memory
|
/// if responsible, deletes memory
|
||||||
~NgArray()
|
~NgArray()
|
||||||
{
|
{
|
||||||
|
if (data)
|
||||||
if (ownmem)
|
if (ownmem)
|
||||||
delete [] data;
|
delete [] data;
|
||||||
}
|
}
|
||||||
@ -374,6 +375,7 @@ namespace netgen
|
|||||||
/// Deallocate memory
|
/// Deallocate memory
|
||||||
void DeleteAll ()
|
void DeleteAll ()
|
||||||
{
|
{
|
||||||
|
if (data)
|
||||||
if (ownmem)
|
if (ownmem)
|
||||||
delete [] data;
|
delete [] data;
|
||||||
data = 0;
|
data = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user