Author: tkreuzer
Date: Mon Dec  1 00:01:17 2014
New Revision: 65536

URL: http://svn.reactos.org/svn/reactos?rev=65536&view=rev
Log:
[WIN32K]
Fix reference counting in PDEVOBJ_pSurface. Fixes failed assertions on newer 
MSVC builds.

Modified:
    trunk/reactos/win32ss/gdi/eng/pdevobj.c

Modified: trunk/reactos/win32ss/gdi/eng/pdevobj.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/pdevobj.c?rev=65536&r1=65535&r2=65536&view=diff
==============================================================================
--- trunk/reactos/win32ss/gdi/eng/pdevobj.c     [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/eng/pdevobj.c     [iso-8859-1] Mon Dec  1 
00:01:17 2014
@@ -81,7 +81,7 @@
     if (ppdev->cPdevRefs == 0)
     {
         /* Do we have a surface? */
-        if(ppdev->pSurface)
+        if (ppdev->pSurface)
         {
             /* Release the surface and let the driver free it */
             SURFACE_ShareUnlockSurface(ppdev->pSurface);
@@ -212,20 +212,18 @@
 {
     HSURF hsurf;
 
-    /* Check if we already have a surface */
-    if (ppdev->pSurface)
-    {
-        /* Increment reference count */
-        GDIOBJ_vReferenceObjectByPointer(&ppdev->pSurface->BaseObject);
-    }
-    else
+    /* Check if there is no surface for this PDEV yet */
+    if (ppdev->pSurface == NULL)
     {
         /* Call the drivers DrvEnableSurface */
         hsurf = ppdev->pldev->pfn.EnableSurface(ppdev->dhpdev);
 
-        /* Lock the surface */
+        /* Get a reference to the surface */
         ppdev->pSurface = SURFACE_ShareLockSurface(hsurf);
     }
+
+    /* Increment reference count */
+    GDIOBJ_vReferenceObjectByPointer(&ppdev->pSurface->BaseObject);
 
     DPRINT("PDEVOBJ_pSurface() returning %p\n", ppdev->pSurface);
     return ppdev->pSurface;


Reply via email to