Memory leaks on errorneous exit fixed

This commit is contained in:
Alexander S. Aganichev
2001-10-21 17:50:03 +00:00
parent 14faad593f
commit b325e0a061
4 changed files with 20 additions and 4 deletions

View File

@@ -1062,6 +1062,9 @@ Area::Area(gmo_area* a) {
Area::~Area() {
if(isopen())
Close();
throw_delete(area);
}

View File

@@ -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)

View File

@@ -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);
}