From 6318758e7119d7834a9f7c4be11b819ee0bfaff4 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 20 Jun 2011 17:42:00 +0200 Subject: TINSEL: Don't leak running processes in Scheduler::reset(). --- engines/tinsel/sched.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'engines') diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp index b24d6bf9b8..d6cd806eb2 100644 --- a/engines/tinsel/sched.cpp +++ b/engines/tinsel/sched.cpp @@ -70,6 +70,7 @@ Scheduler::Scheduler() { active = new PROCESS; active->pPrevious = NULL; + active->pNext = NULL; g_scheduler = this; // FIXME HACK } @@ -113,6 +114,14 @@ void Scheduler::reset() { memset(processList, 'S', MAX_PROCESSES * sizeof(PROCESS)); } + // Kill all running processes (i.e. free memory allocated for their state). + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + delete pProc->state; + pProc->state = 0; + pProc = pProc->pNext; + } + // no active processes pCurrent = active->pNext = NULL; -- cgit v1.2.3