vmwlegacy: Fix a segfault in vmwareCursorCloseScreen.
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 8 Sep 2010 07:57:35 +0000 (09:57 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Wed, 8 Sep 2010 08:00:37 +0000 (10:00 +0200)
The segfault occured because the named function was using resources that
were already taken down, because VMWARECloseScreen was called very late
in the CloseScreen callchain.

Make sure we wrap the CloseScreen pointers late in ScreenInit to avoid this.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
src/vmware.c

index a4e4d08..ed31b02 100644 (file)
@@ -1748,12 +1748,9 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
     fbPictureInit (pScreen, 0, 0);
 
     /*
-     * Save the old screen vector, then wrap CloseScreen and
-     * set SaveScreen.
+     * Save the old screen vector.
      */
     pVMWARE->ScrnFuncs = *pScreen;
-    pScreen->CloseScreen = VMWARECloseScreen;
-    pScreen->SaveScreen = VMWARESaveScreen;
 
     /*
      * Set initial black & white colourmap indices.
@@ -1864,6 +1861,17 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
         }
     }
 
+    /**
+     * Wrap CloseScreen and SaveScreen. Do this late since we
+     * want to be first in the callchain, to avoid using resources
+     * already taken down in CloseScreen.
+     */
+
+    pVMWARE->ScrnFuncs.CloseScreen = pScreen->CloseScreen;
+    pVMWARE->ScrnFuncs.SaveScreen = pScreen->SaveScreen;
+
+    pScreen->CloseScreen = VMWARECloseScreen;
+    pScreen->SaveScreen = VMWARESaveScreen;
 
     /* Done */
     return TRUE;