From e257cb5af2f26ed6a535ce5c52a33ec841aa2618 Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Sun, 24 Jan 1999 19:00:46 +0000 Subject: [PATCH] Moved DOS handle allocation slightly, to fix potential memory leaks and lost handles. Also removed some useless init code. --- loader/dos/dosvm.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/loader/dos/dosvm.c b/loader/dos/dosvm.c index bebc815cf6f..17d6d4a3982 100644 --- a/loader/dos/dosvm.c +++ b/loader/dos/dosvm.c @@ -192,26 +192,11 @@ int DOSVM_Enter( PCONTEXT context ) ERR(module,"No task is currently active!\n"); return -1; } - if (!pModule->lpDosTask) { - /* no VM86 (dosmod) task is currently running, start one */ - if ((lpDosTask = calloc(1, sizeof(DOSTASK))) == NULL) - return 0; - lpDosTask->hModule=pModule->self; - stat=MZ_InitMemory(lpDosTask,pModule); - if (stat>=32) stat=MZ_InitTask(lpDosTask); - if (stat<32) { - free(lpDosTask); - return -1; - } - pModule->lpDosTask = lpDosTask; - pModule->dos_image = lpDosTask->img; - /* Note: we're leaving it running after this, in case we need it again, - as this minimizes the overhead of starting it up every time... - it will be killed automatically when the current task terminates */ - } else lpDosTask=pModule->lpDosTask; - - /* allocate standard DOS handles */ - FILE_InitProcessDosHandles(); + if (!(lpDosTask=pModule->lpDosTask)) { + /* MZ_CreateProcess or MZ_AllocDPMITask should have been called first */ + ERR(module,"dosmod has not been initialized!"); + return -1; + } if (context) { #define CP(x,y) VM86.regs.x = y##_reg(context) @@ -219,6 +204,9 @@ int DOSVM_Enter( PCONTEXT context ) #undef CP } else { /* initial setup */ + /* allocate standard DOS handles */ + FILE_InitProcessDosHandles(); + /* registers */ memset(&VM86,0,sizeof(VM86)); VM86.regs.cs=lpDosTask->init_cs; VM86.regs.eip=lpDosTask->init_ip;