Commit 53d7327c authored by Jason Millard's avatar Jason Millard Committed by Alexandre Julliard

vbscript: Fix memory leak in Split().

(cherry picked from commit f8b76d3d)
parent a6d75af3
......@@ -2572,12 +2572,12 @@ static HRESULT Global_Join(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, V
static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
{
BSTR str, string, delimiter = NULL;
BSTR string, delimiter = NULL;
int count, max, mode, len, start, end, ret, delimiterlen = 1;
int i, *indices = NULL, *new_indices, indices_max = 8;
SAFEARRAYBOUND bounds;
SAFEARRAY *sa = NULL;
VARIANT *data, var;
VARIANT *data;
HRESULT hres = S_OK;
TRACE("%s %u...\n", debugstr_variant(args), args_cnt);
......@@ -2685,19 +2685,13 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
start = 0;
for (i = 0; i < count; i++) {
str = SysAllocStringLen(string + start, indices[i] - start);
if (!str) {
V_VT(&data[i]) = VT_BSTR;
V_BSTR(&data[i]) = SysAllocStringLen(string + start, indices[i] - start);
if (!V_BSTR(&data[i])) {
hres = E_OUTOFMEMORY;
break;
}
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = str;
hres = VariantCopyInd(data+i, &var);
if(FAILED(hres)) {
SafeArrayUnaccessData(sa);
goto error;
}
start = indices[i]+delimiterlen;
}
SafeArrayUnaccessData(sa);
......
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