From 64c1294cc26e034fbf8a9a05b4413f63b9cd882d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 5 Jan 2010 14:10:19 +0000 Subject: [PATCH] x11 tfp: Plug a leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Destroy the dummy XImage we create even on success. http://bugzilla.openedhand.com/show_bug.cgi?id=1918 Based on a patch by: Carlos Martín Nieto Signed-off-by: Emmanuele Bassi --- clutter/x11/clutter-x11-texture-pixmap.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/clutter/x11/clutter-x11-texture-pixmap.c b/clutter/x11/clutter-x11-texture-pixmap.c index 3336d6594..53ed25383 100644 --- a/clutter/x11/clutter-x11-texture-pixmap.c +++ b/clutter/x11/clutter-x11-texture-pixmap.c @@ -213,37 +213,41 @@ try_alloc_shm (ClutterX11TexturePixmap *texture) priv->shminfo.shmid = shmget (IPC_PRIVATE, dummy_image->bytes_per_line * dummy_image->height, - IPC_CREAT|0777); + IPC_CREAT | 0777); if (priv->shminfo.shmid == -1) goto failed_shmget; - priv->shminfo.shmaddr = - shmat (priv->shminfo.shmid, 0, 0); - if (priv->shminfo.shmaddr == (void *)-1) + priv->shminfo.shmaddr = shmat (priv->shminfo.shmid, 0, 0); + if (priv->shminfo.shmaddr == (void *) -1) goto failed_shmat; priv->shminfo.readOnly = False; - if (XShmAttach(dpy, &priv->shminfo) == 0) + if (XShmAttach (dpy, &priv->shminfo) == 0) goto failed_xshmattach; if (clutter_x11_untrap_x_errors ()) g_warning ("X Error: Failed to setup XShm"); + XDestroyImage (dummy_image); + priv->have_shm = TRUE; + return TRUE; failed_xshmattach: g_warning ("XShmAttach failed"); - shmdt(priv->shminfo.shmaddr); + shmdt (priv->shminfo.shmaddr); + failed_shmat: g_warning ("shmat failed"); - shmctl(priv->shminfo.shmid, IPC_RMID, 0); + shmctl (priv->shminfo.shmid, IPC_RMID, 0); + failed_shmget: g_warning ("shmget failed"); - XDestroyImage(dummy_image); -failed_image_create: + XDestroyImage (dummy_image); +failed_image_create: if (clutter_x11_untrap_x_errors ()) g_warning ("X Error: Failed to setup XShm");