diff options
author | Paul Gilbert | 2012-06-17 17:42:29 +1000 |
---|---|---|
committer | Paul Gilbert | 2012-06-17 17:42:29 +1000 |
commit | d24fc8b5d895b595ec62ba1588d734392bc3a5e7 (patch) | |
tree | 80aa56c8a4fa75caa6b3fa88b86967d1f5bd8eea /engines/tony | |
parent | 9405f9eb4aed1d4c248e57ab4972b0132b2253f5 (diff) | |
download | scummvm-rg350-d24fc8b5d895b595ec62ba1588d734392bc3a5e7.tar.gz scummvm-rg350-d24fc8b5d895b595ec62ba1588d734392bc3a5e7.tar.bz2 scummvm-rg350-d24fc8b5d895b595ec62ba1588d734392bc3a5e7.zip |
TONY: Fix memory leak in LocationPollThread
Diffstat (limited to 'engines/tony')
-rw-r--r-- | engines/tony/mpal/mpal.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 72d8d3045c..07042ec077 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -824,12 +824,24 @@ void LocationPollThread(CORO_PARAM, const void *param) { MYACTION *MyActions; MYTHREAD *MyThreads; + + ~CoroContextTag() { + // Free data blocks + if (MyThreads) + globalDestroy(MyThreads); + if (MyActions) + globalDestroy(MyActions); + } CORO_END_CONTEXT(_ctx); uint32 id = *((const uint32 *)param); CORO_BEGIN_CODE(_ctx); + /* Initialise data pointers */ + _ctx->MyActions = NULL; + _ctx->MyThreads = NULL; + /* To begin with, we need to request the item list from the location */ _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); @@ -1045,12 +1057,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip off CORO_INVOKE_4(GLOBALS._lplpFunctions[201], 0, 0, 0, 0); - /* We're finished */ - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); - - CORO_KILL_SELF(); - CORO_END_CODE; } |