[PATCH 0/1] MR1107: kernelbase: Avoid memory leaks in GetConsoleTitleW()
From: Hugh McMaster <hugh.mcmaster(a)outlook.com> --- dlls/kernelbase/console.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index e3b0ebead9e..30e95bcb84b 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -1059,9 +1059,9 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW( LPWSTR title, DWORD size ) if (!console_ioctl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, IOCTL_CONDRV_GET_TITLE, NULL, 0, params, max_size, &size )) - return 0; + goto error; - if (size < sizeof(*params)) return 0; + if (size < sizeof(*params)) goto error; size -= sizeof(*params); memcpy( title, params->buffer, size ); @@ -1069,6 +1069,10 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW( LPWSTR title, DWORD size ) size = params->title_len; HeapFree( GetProcessHeap(), 0, params ); return size; + +error: + HeapFree( GetProcessHeap(), 0, params ); + return 0; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1107
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125133 Your paranoid android. === debian11 (32 bit report) === ddraw: ddraw7.c:15663: Test failed: Expected unsynchronised map for flags 0x1000. ddraw7.c:15663: Test failed: Expected unsynchronised map for flags 0x3000. dxva2: dxva2: Timeout evr: evr: Timeout explorerframe: nstc: Timeout taskbarlist: Timeout gameux: gameexplorer: Timeout gamestatistics: Timeout gdi32: bitmap: Timeout brush: Timeout clipping: Timeout dc: Timeout dib: Timeout driver: Timeout font: Timeout gdiobj: Timeout icm: Timeout mapping: Timeout metafile: Timeout palette: Timeout Report validation errors: path: Timeout === debian11 (build log) === WineRunWineTest.pl:error: The task timed out
Hi Hugh, IMO, this could be written without using 'goto' for example ``` if (console_ioctl(...) && size >= sizeof(...)) { } else size = 0; HeapFree(...); return size; ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1107#note_11327
participants (4)
-
eric pouech (@epo) -
Hugh McMaster -
Hugh McMaster (@hmc) -
Marvin