[Spice-devel] [PATCH qxl-win v3] display/surface: FreeSurfaceInfo: ignore double frees

Alon Levy alevy at redhat.com
Thu Jul 7 02:43:37 PDT 2011


Cc: Yonit Halperin <yhalperi at redhat.com>
---
 display/surface.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/display/surface.h b/display/surface.h
index e677610..0b7edb3 100644
--- a/display/surface.h
+++ b/display/surface.h
@@ -55,10 +55,16 @@ static _inline void FreeSurfaceInfo(PDev *pdev, UINT32 surface_id)
     if (surface_id == 0) {
         return;
     }
-
     EngAcquireSemaphore(pdev->Res->surface_sem);
 
+    DEBUG_PRINT((pdev, 9, "%s: %p: %d\n", __FUNCTION__, pdev, surface_id));
     surface = &pdev->Res->surfaces_info[surface_id];
+    if (surface->draw_area.base_mem == NULL) {
+        DEBUG_PRINT((pdev, 9, "%s: %p: %d: double free. safely ignored\n", __FUNCTION__,
+            pdev, surface_id));
+        EngReleaseSemaphore(pdev->Res->surface_sem);
+        return;
+    }
     surface->draw_area.base_mem = NULL; /* Mark as not used */
     surface->u.next_free = pdev->Res->free_surfaces;
     pdev->Res->free_surfaces = surface;
-- 
1.7.5.4



More information about the Spice-devel mailing list