From 09f9986ea1270ae43c9ff606592caf8c111259c8 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Mon, 29 Aug 2016 13:50:34 +0200 Subject: [PATCH] winedevice: Avoid memory leak when driver cannot be unloaded. Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- programs/winedevice/device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c index e1a38a49a0b..5011e4f50fc 100644 --- a/programs/winedevice/device.c +++ b/programs/winedevice/device.c @@ -478,7 +478,13 @@ static NTSTATUS create_driver( const WCHAR *driver_name ) static void wine_drivers_rb_destroy( struct wine_rb_entry *entry, void *context ) { - unload_driver( entry, TRUE ); + if (unload_driver( entry, TRUE ) != STATUS_SUCCESS) + { + struct wine_driver *driver = WINE_RB_ENTRY_VALUE( entry, struct wine_driver, entry ); + ObDereferenceObject( driver->driver_obj ); + CloseServiceHandle( (void *)driver->handle ); + HeapFree( GetProcessHeap(), 0, driver ); + } } static void WINAPI async_shutdown_drivers( PTP_CALLBACK_INSTANCE instance, void *context )