From a794e3f2d0d0ab85b85115c103b0feec0a12e8e2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 21 Apr 2014 17:09:27 +0000 Subject: [PATCH] [WIN32K] Do not ignore failure when calling DrvEnablePDEV and properly handle a failure in PDEVOBJ_bEnablePDEV instead of ASSERTing. Properly cleanup the PDEV after failure, check if the PDEV was enabled before calling DrvDisablePDEV. Fixes some crashes with VBox driver. svn path=/trunk/; revision=62855 --- reactos/win32ss/gdi/eng/pdevobj.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/reactos/win32ss/gdi/eng/pdevobj.c b/reactos/win32ss/gdi/eng/pdevobj.c index 8e5a4d0bb26..a2feddc8897 100644 --- a/reactos/win32ss/gdi/eng/pdevobj.c +++ b/reactos/win32ss/gdi/eng/pdevobj.c @@ -94,8 +94,12 @@ PDEVOBJ_vRelease(PPDEVOBJ ppdev) PALETTE_ShareUnlockPalette(ppdev->ppalSurf); } - /* Disable PDEV */ - ppdev->pfn.DisablePDEV(ppdev->dhpdev); + /* Check if the PDEV was enabled */ + if (ppdev->dhpdev != NULL) + { + /* Disable the PDEV */ + ppdev->pfn.DisablePDEV(ppdev->dhpdev); + } /* Remove it from list */ if( ppdev == gppdevList ) @@ -155,6 +159,11 @@ PDEVOBJ_bEnablePDEV( (HDEV)ppdev, ppdev->pGraphicsDevice->pwszDescription, ppdev->pGraphicsDevice->DeviceObject); + if (ppdev->dhpdev == NULL) + { + DPRINT1("Failed to enable PDEV\n"); + return FALSE; + } /* Fix up some values */ if (ppdev->gdiinfo.ulLogPixelsX == 0) @@ -337,7 +346,8 @@ EngpCreatePDEV( if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL)) { DPRINT1("Failed to enable PDEV!\n"); - ASSERT(FALSE); + PDEVOBJ_vRelease(ppdev); + return NULL; } /* FIXME: this must be done in a better way */