vbscript: Fix possible memory leak/crash caused by race condition in VBScriptParse_InitNew.

This commit is contained in:
Octavian Voicu 2011-09-01 05:23:12 +03:00 committed by Alexandre Julliard
parent 45725be9d5
commit 2f053965a2

View File

@ -348,7 +348,7 @@ static ULONG WINAPI VBScriptParse_Release(IActiveScriptParse *iface)
static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface)
{
VBScript *This = impl_from_IActiveScriptParse(iface);
script_ctx_t *ctx;
script_ctx_t *ctx, *old_ctx;
TRACE("(%p)\n", This);
@ -359,8 +359,8 @@ static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface)
if(!ctx)
return E_OUTOFMEMORY;
ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL);
if(ctx) {
old_ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL);
if(old_ctx) {
destroy_script(ctx);
return E_UNEXPECTED;
}