Hi,

I am sorry, the last mail had the wrong patch attached. Still fighting
with git... Here's the correct patch.


Sven



>From 04ff8bb62ca58ce5c77630bd5513ccdc778cf576 Mon Sep 17 00:00:00 2001
From: Sven Neumann <s.neum...@phase-zero.de>
Date: Tue, 10 Mar 2009 19:29:45 +0100
Subject: [PATCH] avoid double free if XShm is not available

---
 systems/x11/xwindow.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/systems/x11/xwindow.c b/systems/x11/xwindow.c
index 7b84383..c441e82 100644
--- a/systems/x11/xwindow.c
+++ b/systems/x11/xwindow.c
@@ -240,7 +240,10 @@ no_shm:
 
           pitch = (xw->bpp * xw->width + 3) & ~3;
 
-          xw->virtualscreen = D_MALLOC( 2 * xw->height * pitch );
+          /* Use malloc(), not D_MALLOC() here, because XCreateImage()
+           * will call free() on this data.
+           */
+          xw->virtualscreen = malloc ( 2 * xw->height * pitch );
 
           xw->ximage = XCreateImage( xw->display, xw->visual, xw->depth, ZPixmap, 0,
                                      xw->virtualscreen, xw->width, xw->height * 2, 32, pitch );
@@ -277,14 +280,12 @@ dfb_x11_close_window( DFBX11 *x11, XWindow* xw )
           shmctl(xw->shmseginfo->shmid,IPC_RMID,NULL);
           D_FREE(xw->shmseginfo);
      }
-     else
-          D_FREE( xw->virtualscreen );
 
      XDestroyImage(xw->ximage);
 
      XFreeGC(xw->display,xw->gc);
      XDestroyWindow(xw->display,xw->window);
-	
+
      D_FREE(xw);
 }
 
-- 
1.6.2

_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to