[PATCH 2/2] jscript: Fixed a leak in regexp_match function
Piotr Caban
piotr.caban at gmail.com
Fri Jan 25 09:52:06 CST 2013
On 01/25/13 16:30, Marcus Meissner wrote:
> On Fri, Jan 25, 2013 at 04:26:59PM +0100, Piotr Caban wrote:
>> @@ -3466,10 +3466,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);
>
> Should be probably if (ret) heap_free(old_ret); here.
I think it's correct. I want to free old buffer in case of HeapRealloc
error.
More information about the wine-devel
mailing list