Summary: Add missing checks on locks when resizing
Source: MontaVista Software, Inc.  Ryan Burns <source@mvista.com>
Type: Defect Fix
Description: When an input event triggers a resize operation, the surface is destroyed and replaced by a new one. Durring this operation, it is possible for a drawing routine to use this data. If this happens, the drawing routine will segfault writing to memory that has been freed. This patch adds the necessary code to ensure that there are no conflicts when accessing the surface data.
--- DirectFB-0.9.24.clean/src/core/surfaces.c	2005-10-24 09:55:16.000000000 -0700
+++ DirectFB-0.9.24.fix/src/core/surfaces.c	2005-12-05 15:44:06.000000000 -0800
@@ -352,6 +352,8 @@
 {
      int old_width, old_height;
      DFBSurfacePixelFormat old_format;
+     SurfaceBuffer	*front;
+     SurfaceBuffer	*back;
      DFBResult ret;
 
      D_DEBUG_AT( Core_Surface, "dfb_surface_reformat( %p, %dx%d, %s )\n",
@@ -369,7 +371,22 @@
           return DFB_UNSUPPORTED;
      }
 
-     dfb_surfacemanager_lock( surface->manager );
+
+     front = surface->front_buffer;
+     back = surface->back_buffer;
+     while (1) 
+     {
+	  dfb_surfacemanager_lock( surface->manager );
+	 if ((front->system.locked) || (front->video.locked) || (back->system.locked) || (back->video.locked))
+         {
+               dfb_surfacemanager_unlock( surface->manager );
+               sched_yield();
+	 }
+	  else
+		  break;
+     
+     }
+
 
      old_width  = surface->width;
      old_height = surface->height;
