Commit 2f053965 authored by Octavian Voicu's avatar Octavian Voicu Committed by Alexandre Julliard

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

parent 45725be9
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment