https://bugs.winehq.org/show_bug.cgi?id=54458
Bug ID: 54458 Summary: vbscript memory leaks in Global_Split Product: Wine Version: 7.21 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: vbscript Assignee: wine-bugs@winehq.org Reporter: jsm174@gmail.com Distribution: ---
While porting Visual Pinball to cross platform, I started using XCode Instruments to find some outstanding memory leaks.
There appears to be a memory leak in Global_Split.
The BSTRs that get copied from "var" into the SafeArray using VariantCopyInd are never freed.
The following code changes fix this:
for (i = 0; i < count; i++) { str = SysAllocStringLen(string + start, indices[i] - start); if (!str) { hres = E_OUTOFMEMORY; break; } V_VT(&var) = VT_BSTR; V_BSTR(&var) = str;
hres = VariantCopyInd(data+i, &var); if(FAILED(hres)) { SafeArrayUnaccessData(sa); SysFreeString(str); goto error; } start = indices[i]+delimiterlen; SysFreeString(str); }