From c45c7bf94cb41f30149f2e81d72bbe3f4e6096c0 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Fri, 25 Jan 2013 16:48:07 +0100 Subject: [PATCH] jscript: Fixed a leak in regexp_match function. --- dlls/jscript/regexp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c index a06550d3c75..65ddc241461 100644 --- a/dlls/jscript/regexp.c +++ b/dlls/jscript/regexp.c @@ -3464,10 +3464,15 @@ static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *str, B break; if(ret_size == i) { - if(ret) - ret = heap_realloc(ret, (ret_size <<= 1) * sizeof(match_result_t)); - else + if(ret) { + match_result_t *old_ret = ret; + + ret = heap_realloc(old_ret, (ret_size <<= 1) * sizeof(match_result_t)); + if(!ret) + heap_free(old_ret); + }else { ret = heap_alloc((ret_size=4) * sizeof(match_result_t)); + } if(!ret) { hres = E_OUTOFMEMORY; break; -- 2.11.4.GIT