[PATCH 0/1] MR8019: wineps.drv: Avoid double destroy of PSDRV_Heap.
I hope I read the code right: if `DLL_PROCESS_ATTACH` fails, `DllMain` will immediately be called again with `DLL_PROCESS_DETACH`, which will try to destroy the already destroyed `PSDRV_Heap`. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8019
From: Yuxuan Shui <yshui(a)codeweavers.com> --- dlls/wineps.drv/init.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 7128177c94f..9c306daf3de 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -305,15 +305,12 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) if (PSDRV_Heap == NULL) return FALSE; - if (PSDRV_GetFontMetrics() == FALSE) { - HeapDestroy(PSDRV_Heap); + if (PSDRV_GetFontMetrics() == FALSE) return FALSE; - } if (!convert_afm_to_ntf() || !import_ntf_from_reg()) { WINE_UNIX_CALL(unix_free_printer_info, NULL); - HeapDestroy(PSDRV_Heap); return FALSE; } break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8019
Do we need this private heap at all? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8019#note_103149
On Tue May 13 22:07:23 2025 +0000, Nikolay Sivov wrote:
Do we need this private heap at all? From PSDRV_GetFontMetrics():
``` * If this function fails, PSDRV_Init will destroy PSDRV_Heap, so don't worry * about freeing all the memory that's been allocated. ``` It looks like naïvely replacing PSDRV\_Heap with GetProcessHeap() will result in memory leak, as it's using the heap as sort of a local arena. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8019#note_103231
This merge request was approved by Huw Davies. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8019
participants (5)
-
Huw Davies (@huw) -
Jinoh Kang (@iamahuman) -
Nikolay Sivov (@nsivov) -
Yuxuan Shui -
Yuxuan Shui (@yshui)