From 12adc677820f59a7d079eec26cf3a998a222f4a0 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 31 Oct 2012 10:21:09 +0100 Subject: [PATCH] jscript: Fixed some leaks (coverity). --- dlls/jscript/dispex.c | 4 +++- dlls/jscript/function.c | 4 +++- dlls/jscript/number.c | 4 +++- dlls/jscript/vbarray.c | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 211ed8a7676..2be474edf5b 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -901,8 +901,10 @@ HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsd return E_OUTOFMEMORY; hres = init_dispex(ret, ctx, builtin_info ? builtin_info : &dispex_info, prototype); - if(FAILED(hres)) + if(FAILED(hres)) { + heap_free(ret); return hres; + } *dispex = ret; return S_OK; diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 4cac3d6665b..c5bcd2ea9d3 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -578,8 +578,10 @@ static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_ hres = init_dispex_from_constr(&function->dispex, ctx, builtin_info, ctx->function_constr); else hres = init_dispex_from_constr(&function->dispex, ctx, &FunctionInst_info, ctx->function_constr); - if(FAILED(hres)) + if(FAILED(hres)) { + heap_free(function); return hres; + } function->flags = flags; function->length = flags & PROPF_ARGMASK; diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c index b7a1a765bbd..ed773a32497 100644 --- a/dlls/jscript/number.c +++ b/dlls/jscript/number.c @@ -609,8 +609,10 @@ static HRESULT alloc_number(script_ctx_t *ctx, jsdisp_t *object_prototype, Numbe hres = init_dispex(&number->dispex, ctx, &Number_info, object_prototype); else hres = init_dispex_from_constr(&number->dispex, ctx, &NumberInst_info, ctx->number_constr); - if(FAILED(hres)) + if(FAILED(hres)) { + heap_free(number); return hres; + } *ret = number; return S_OK; diff --git a/dlls/jscript/vbarray.c b/dlls/jscript/vbarray.c index 58788662d2d..7b9993b3382 100644 --- a/dlls/jscript/vbarray.c +++ b/dlls/jscript/vbarray.c @@ -184,6 +184,8 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un if(r) *r = jsval_obj(array); + else + jsdisp_release(array); return S_OK; }