From b325e0a06182770bffc898faabe9d7576245d8ff Mon Sep 17 00:00:00 2001 From: "Alexander S. Aganichev" Date: Sun, 21 Oct 2001 17:50:03 +0000 Subject: [PATCH] Memory leaks on errorneous exit fixed --- docs/notework.txt | 2 ++ golded3/gcarea.cpp | 3 +++ golded3/gedoss.cpp | 17 +++++++++++++---- golded3/geread.cpp | 2 ++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/notework.txt b/docs/notework.txt index 93a8503..f333d4d 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -12,6 +12,8 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, /snapshot/ ______________________________________________________________________ +- Thanks to Pavel Tsekov few more memory leaks was eliminated. + ! Added "COLOR READER URL" for highlighting URLs and e-mail's. ! Message now saved by default in local codepage. diff --git a/golded3/gcarea.cpp b/golded3/gcarea.cpp index 8e1241c..4afd4a5 100644 --- a/golded3/gcarea.cpp +++ b/golded3/gcarea.cpp @@ -1062,6 +1062,9 @@ Area::Area(gmo_area* a) { Area::~Area() { + if(isopen()) + Close(); + throw_delete(area); } diff --git a/golded3/gedoss.cpp b/golded3/gedoss.cpp index a2f9576..0a8b007 100644 --- a/golded3/gedoss.cpp +++ b/golded3/gedoss.cpp @@ -37,6 +37,8 @@ extern GPickArealist* PickArealist; extern bool in_arealist; +extern uint* areanumbers; +extern GMsg* reader_msg; // ------------------------------------------------------------------ // Clean up the screen, memory and files before exiting to DOS @@ -48,6 +50,14 @@ void Cleanup(void) { if(CFG->switches.get(areakeeplast) and startupscan_success) AL.WriteGoldLast(); + // Free msg data + if (reader_msg != NULL) { + ResetMsg(reader_msg); + throw_release(reader_msg); + } + // Free area data + AL.Reset(); + #ifndef GMB_NOXBBS if(AL.msgbases & MT_ADEPTXBBS) XbbsExit(); @@ -89,9 +99,6 @@ void Cleanup(void) { SearchExit(); - // Free area data - AL.Reset(); - // Free various lists CFG->addressmacro.clear(); CFG->aka.clear(); @@ -136,8 +143,10 @@ void Cleanup(void) { gvid->setoverscan(gvid->orig.color.overscan); wcloseall(); // Close all windows - if(in_arealist) + if(in_arealist) { PickArealist->close_all(); // Unlink hidden area windows + throw_release(areanumbers); + } whelpundef(); // Disengage the help system kbclear(); // Clear CXL keyboard buffer freonkey(); // Free all onkeys (macros) diff --git a/golded3/geread.cpp b/golded3/geread.cpp index 8a99d8d..43b95ad 100644 --- a/golded3/geread.cpp +++ b/golded3/geread.cpp @@ -795,6 +795,8 @@ void Reader() { ResetMsg(msg); throw_free(msg); + // Invalidate reader_msg since the actual data has just been freed. + reader_msg = NULL; HandleGEvent(EVTT_EXIT); }