From 744a23d0aa198e796b790cb01be9d86b58a29edb Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 6 May 2009 18:55:20 +0000 Subject: [PATCH] fix leaks; make destructors virtual --- src/ATCDCL/ATCVoice.cxx | 3 +++ src/GUI/dialog.hxx | 2 +- src/GUI/gui_funcs.cxx | 3 +++ src/Input/fgjs.cxx | 1 + src/Instrumentation/od_gauge.hxx | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ATCDCL/ATCVoice.cxx b/src/ATCDCL/ATCVoice.cxx index 682cd24a4..e4b05b75c 100644 --- a/src/ATCDCL/ATCVoice.cxx +++ b/src/ATCDCL/ATCVoice.cxx @@ -151,6 +151,7 @@ unsigned char* FGATCVoice::WriteMessage(char* message, int& len, bool& dataOK) { // Check for no tokens found else slScheduler can be crashed if(!word) { dataOK = false; + delete[] wdptr; return(NULL); } @@ -170,6 +171,8 @@ unsigned char* FGATCVoice::WriteMessage(char* message, int& len, bool& dataOK) { SG_LOG(SG_ATC, SG_ALERT, "Offset + length: " << wdptr[i].offset + wdptr[i].length << " exceeds rawdata size: " << rawDataSize << endl); delete[] wdptr; + delete[] tmpbuf; + delete[] outbuf; dataOK = false; return(NULL); } diff --git a/src/GUI/dialog.hxx b/src/GUI/dialog.hxx index fcd1ca7d3..749c355cb 100644 --- a/src/GUI/dialog.hxx +++ b/src/GUI/dialog.hxx @@ -21,7 +21,7 @@ using std::vector; #define FGCLASS_LIST 0x00000001 #define FGCLASS_AIRPORTLIST 0x00000002 #define FGCLASS_PROPERTYLIST 0x00000004 -class GUI_ID { public: GUI_ID(int id) : id(id) {} int id; }; +class GUI_ID { public: GUI_ID(int id) : id(id) {} virtual ~GUI_ID() {} int id; }; diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index 574611196..1dc5db7a4 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -246,6 +246,7 @@ void fgHiResDump() /* allocate buffer large enough to store one tile */ GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte)); if (!tile) { + delete [] filename; printf("Malloc of tile buffer failed!\n"); return; } @@ -257,6 +258,7 @@ void fgHiResDump() GLubyte *buffer = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte)); if (!buffer) { + delete [] filename; free(tile); printf("Malloc of tile row buffer failed!\n"); return; @@ -283,6 +285,7 @@ void fgHiResDump() f = fopen(filename, "wb"); if (!f) { printf("Couldn't open image file: %s\n", filename); + delete [] filename; free(buffer); free(tile); return; diff --git a/src/Input/fgjs.cxx b/src/Input/fgjs.cxx index 81c4cdda0..5527514d5 100644 --- a/src/Input/fgjs.cxx +++ b/src/Input/fgjs.cxx @@ -211,6 +211,7 @@ int main( int argc, char *argv[] ) { delete jsi; delete[] xfs; delete jss; + delete[] jstree; return 1; } diff --git a/src/Instrumentation/od_gauge.hxx b/src/Instrumentation/od_gauge.hxx index 2c957d429..3b3217d5b 100644 --- a/src/Instrumentation/od_gauge.hxx +++ b/src/Instrumentation/od_gauge.hxx @@ -38,7 +38,7 @@ class FGODGauge : public SGSubsystem { public: FGODGauge ( SGPropertyNode *node ); FGODGauge(); - ~FGODGauge(); + virtual ~FGODGauge(); virtual void init (); virtual void update (double dt);