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`.
From: Yuxuan Shui yshui@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;
Do we need this private heap at all?
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.
This merge request was approved by Huw Davies.