[Spice-devel] [PATCH] spice-widget-x11.c: Fix change color parameter 16 bits to 32 bits

Matilde Yanez yanez.matilde at gmail.com
Tue Nov 27 04:48:42 PST 2012


Hello,

Issue description:
Running remote-viewer with QXL and X11 display.
In VM, windows clients, change color parameter  16bits to 32 bits
involves a remote-viewer crash.
"glibc detected free() invalid pointer type".
The following patch resolves this issue.


patch:

diff --git a/tmp/spice-gtk-git-26-nov/gtk/spice-widget-x11.c
b/gtk/spice-widget-x11.c
index 05b8d56..10aeeb6 100644
--- a/tmp/spice-gtk-git-26-nov/gtk/spice-widget-x11.c
+++ b/gtk/spice-widget-x11.c
@@ -144,7 +144,7 @@ int spicex_image_create(SpiceDisplay *display)
         g_return_val_if_fail(d->vi != NULL, 1);
     }
     if (d->convert) {
-        d->data = g_malloc0(d->height * d->stride); /* pixels are 32 bits */
+    	d->data = g_malloc(d->height * d->stride); /* pixels are 32 bits */
     }

     d->gc = XCreateGC(d->dpy, gdk_x11_drawable_get_xid(window),
@@ -200,8 +200,13 @@ void spicex_image_destroy(SpiceDisplay *display)
             d->ximage->data = NULL;
         XDestroyImage(d->ximage);
         d->ximage = NULL;
-        if (d->convert)
-            d->data = 0;
+        if(d->convert){
+        	if(d->data){
+        		d->data = 0;
+        		g_free(d->data);
+        		d->data = NULL;
+        	}
+        }
     }
     if (d->shminfo) {
         XShmDetach(d->dpy, d->shminfo);
@@ -212,10 +217,6 @@ void spicex_image_destroy(SpiceDisplay *display)
         XFreeGC(d->dpy, d->gc);
         d->gc = NULL;
     }
-    if (d->convert && d->data) {
-        g_free(d->data);
-        d->data = NULL;
-    }
 }

 G_GNUC_INTERNAL


More information about the Spice-devel mailing list