mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-28 15:22:27 +00:00
Fix new[]/delete missmatches and memory leaks found by clang's ASAN
Sometimes memory was allocated with new[] but freed with delete instead of delete[], which is wrong. And there were some small memory leaks, too. Furtunately clang's AddressSanitizer detected all that so I could easily fix it. (There seem to be some more small memory leaks which are harder to fix, though)
This commit is contained in:
parent
018e13feef
commit
86c634b55c
3 changed files with 13 additions and 8 deletions
|
@ -861,20 +861,20 @@ idPVS::Shutdown
|
||||||
*/
|
*/
|
||||||
void idPVS::Shutdown( void ) {
|
void idPVS::Shutdown( void ) {
|
||||||
if ( connectedAreas ) {
|
if ( connectedAreas ) {
|
||||||
delete connectedAreas;
|
delete[] connectedAreas;
|
||||||
connectedAreas = NULL;
|
connectedAreas = NULL;
|
||||||
}
|
}
|
||||||
if ( areaQueue ) {
|
if ( areaQueue ) {
|
||||||
delete areaQueue;
|
delete[] areaQueue;
|
||||||
areaQueue = NULL;
|
areaQueue = NULL;
|
||||||
}
|
}
|
||||||
if ( areaPVS ) {
|
if ( areaPVS ) {
|
||||||
delete areaPVS;
|
delete[] areaPVS;
|
||||||
areaPVS = NULL;
|
areaPVS = NULL;
|
||||||
}
|
}
|
||||||
if ( currentPVS ) {
|
if ( currentPVS ) {
|
||||||
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
|
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
|
||||||
delete currentPVS[i].pvs;
|
delete[] currentPVS[i].pvs;
|
||||||
currentPVS[i].pvs = NULL;
|
currentPVS[i].pvs = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -861,20 +861,20 @@ idPVS::Shutdown
|
||||||
*/
|
*/
|
||||||
void idPVS::Shutdown( void ) {
|
void idPVS::Shutdown( void ) {
|
||||||
if ( connectedAreas ) {
|
if ( connectedAreas ) {
|
||||||
delete connectedAreas;
|
delete[] connectedAreas;
|
||||||
connectedAreas = NULL;
|
connectedAreas = NULL;
|
||||||
}
|
}
|
||||||
if ( areaQueue ) {
|
if ( areaQueue ) {
|
||||||
delete areaQueue;
|
delete[] areaQueue;
|
||||||
areaQueue = NULL;
|
areaQueue = NULL;
|
||||||
}
|
}
|
||||||
if ( areaPVS ) {
|
if ( areaPVS ) {
|
||||||
delete areaPVS;
|
delete[] areaPVS;
|
||||||
areaPVS = NULL;
|
areaPVS = NULL;
|
||||||
}
|
}
|
||||||
if ( currentPVS ) {
|
if ( currentPVS ) {
|
||||||
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
|
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
|
||||||
delete currentPVS[i].pvs;
|
delete[] currentPVS[i].pvs;
|
||||||
currentPVS[i].pvs = NULL;
|
currentPVS[i].pvs = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,11 @@ public:
|
||||||
explicit idPolynomial( float a, float b, float c, float d );
|
explicit idPolynomial( float a, float b, float c, float d );
|
||||||
explicit idPolynomial( float a, float b, float c, float d, float e );
|
explicit idPolynomial( float a, float b, float c, float d, float e );
|
||||||
|
|
||||||
|
~idPolynomial() // DG: don't leak coefficient's memory!
|
||||||
|
{
|
||||||
|
Mem_Free16( coefficient );
|
||||||
|
}
|
||||||
|
|
||||||
float operator[]( int index ) const;
|
float operator[]( int index ) const;
|
||||||
float & operator[]( int index );
|
float & operator[]( int index );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue