diff --git a/checkin_notes b/checkin_notes index de6194bd9a..c6a5fa0b5e 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6779,3 +6779,10 @@ Rom & Charlie 18 Aug 2008 clientscr/ screensaver.cpp + +Eric 18 Aug 2008 + - Fixed potential memory leak and other minor problems with + APP_INIT_DATA. + + lib/ + app_ipc.[Ch] diff --git a/lib/app_ipc.C b/lib/app_ipc.C index a35cb25678..d860a2fab0 100644 --- a/lib/app_ipc.C +++ b/lib/app_ipc.C @@ -48,8 +48,7 @@ GRAPHICS_MSG::GRAPHICS_MSG() { memset(this, 0, sizeof(GRAPHICS_MSG)); } -APP_INIT_DATA::APP_INIT_DATA() { - project_preferences = 0; +APP_INIT_DATA::APP_INIT_DATA() : project_preferences(NULL) { } APP_INIT_DATA::~APP_INIT_DATA() { @@ -63,8 +62,11 @@ APP_INIT_DATA::APP_INIT_DATA(const APP_INIT_DATA& a) { copy(a); } -void APP_INIT_DATA::operator=(const APP_INIT_DATA& a) { - copy(a); +APP_INIT_DATA &APP_INIT_DATA::operator=(const APP_INIT_DATA& a) { + if (this != &a) { + copy(a); + } + return *this; } void APP_INIT_DATA::copy(const APP_INIT_DATA& a) { @@ -253,9 +255,9 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) { return ERR_XML_PARSE; } -APP_CLIENT_SHM::APP_CLIENT_SHM() { - shm = 0; +APP_CLIENT_SHM::APP_CLIENT_SHM() : shm(NULL) { } + bool MSG_CHANNEL::get_msg(char *msg) { if (!buf[0]) return false; strlcpy(msg, buf+1, MSG_CHANNEL_SIZE-1); diff --git a/lib/app_ipc.h b/lib/app_ipc.h index 14ee96c163..62fb9f65cd 100644 --- a/lib/app_ipc.h +++ b/lib/app_ipc.h @@ -192,7 +192,7 @@ struct APP_INIT_DATA { APP_INIT_DATA(); APP_INIT_DATA(const APP_INIT_DATA&); // copy constructor - void operator=(const APP_INIT_DATA&); + APP_INIT_DATA &operator=(const APP_INIT_DATA&); void copy(const APP_INIT_DATA&); // actually do the copy here ~APP_INIT_DATA(); };