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); }
https://bugs.winehq.org/show_bug.cgi?id=54458
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com --- This looks correct, but you could have a single free call right after VariantCopyInd().
https://bugs.winehq.org/show_bug.cgi?id=54458
--- Comment #2 from Jason Millard jsm174@gmail.com --- Perfect. If I were to submit an MR for this, how would one go about a test case?
https://bugs.winehq.org/show_bug.cgi?id=54458
--- Comment #3 from Nikolay Sivov bunglehead@gmail.com --- For tests we only need to make sure that Split() is tested at all. Then to detect leaks the tests are executed using some leak detection tool. With wine I know people are using valgrind on Linux. I don't know how well it works with current wine/valgrind. But basically, there is no direct support to detect such issues in our tests, you only need to make sure functionality is executed, so the test can potentially trigger the leak.
https://bugs.winehq.org/show_bug.cgi?id=54458
--- Comment #4 from Jason Millard jsm174@gmail.com --- Fixed with https://gitlab.winehq.org/wine/wine/-/merge_requests/2131
https://bugs.winehq.org/show_bug.cgi?id=54458
Jason Millard jsm174@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
--- Comment #5 from Jason Millard jsm174@gmail.com --- Resolved.
https://bugs.winehq.org/show_bug.cgi?id=54458
--- Comment #6 from Nikolay Sivov bunglehead@gmail.com --- Please mention final commits ids when resolving bugs:
https://source.winehq.org/git/wine.git/commit/f8b76d3da549f8f08a0413de438f92... https://source.winehq.org/git/wine.git/commit/a6847dd9fb3d9ce876e59e776b2a17...
https://bugs.winehq.org/show_bug.cgi?id=54458
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |f8b76d3da549f8f08a0413de438 | |f929702a380af
https://bugs.winehq.org/show_bug.cgi?id=54458
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #7 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 8.2.
https://bugs.winehq.org/show_bug.cgi?id=54458
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |8.0.x
https://bugs.winehq.org/show_bug.cgi?id=54458
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|8.0.x |---
--- Comment #8 from Michael Stefaniuc mstefani@winehq.org --- Removing the 8.0.x milestone from bug fixes included in 8.0.1.