mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-15 15:30:34 +05:00
Two nullptr deref fixes in table
Don't delete memory that wasn't allocated. Similarly, we can't deref the first element of an array that was never allocated.
This commit is contained in:
parent
6ba4a6e6c6
commit
ae87c7005c
@ -109,8 +109,10 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
void * p = new char [(line.maxsize+5) * elsize];
|
void * p = new char [(line.maxsize+5) * elsize];
|
||||||
|
|
||||||
|
if (line.size > 0 && line.col != NULL) {
|
||||||
memcpy (p, line.col, line.maxsize * elsize);
|
memcpy (p, line.col, line.maxsize * elsize);
|
||||||
delete [] (char*)line.col;
|
delete [] (char*)line.col;
|
||||||
|
}
|
||||||
|
|
||||||
line.col = p;
|
line.col = p;
|
||||||
line.maxsize += 5;
|
line.maxsize += 5;
|
||||||
|
@ -120,7 +120,8 @@ public:
|
|||||||
|
|
||||||
/// Creates fixed maximal element size table
|
/// Creates fixed maximal element size table
|
||||||
inline TABLE (const NgFlatArray<int,BASE> & entrysizes)
|
inline TABLE (const NgFlatArray<int,BASE> & entrysizes)
|
||||||
: BASE_TABLE (NgFlatArray<int> (entrysizes.Size(), const_cast<int*>(&entrysizes[BASE])),
|
: BASE_TABLE (NgFlatArray<int> (entrysizes.Size(),
|
||||||
|
entrysizes.Size() > 0 ? const_cast<int*>(&entrysizes[BASE]) : 0),
|
||||||
sizeof(T))
|
sizeof(T))
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user