[cairo-commit] src/cairo-list-inline.h src/cairo-xlib-visual.c
Chris Wilson
ickle at kemper.freedesktop.org
Mon Jun 3 07:00:35 PDT 2013
src/cairo-list-inline.h | 8 +++++++-
src/cairo-xlib-visual.c | 3 +++
2 files changed, 10 insertions(+), 1 deletion(-)
New commits:
commit 85c2a0d76ab109f2bec8f7dccab577033e6d37b0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Mon Jun 3 13:56:00 2013 +0100
xlib: Unlike the visual when destroying it
Otherwise we leave dangling pointers in the visual list, leading to
memory corruption when using low bitdepth servers.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-list-inline.h b/src/cairo-list-inline.h
index d00f40e..0955178 100644
--- a/src/cairo-list-inline.h
+++ b/src/cairo-list-inline.h
@@ -145,9 +145,15 @@ __cairo_list_del (cairo_list_t *prev, cairo_list_t *next)
}
static inline void
-cairo_list_del (cairo_list_t *entry)
+_cairo_list_del (cairo_list_t *entry)
{
__cairo_list_del (entry->prev, entry->next);
+}
+
+static inline void
+cairo_list_del (cairo_list_t *entry)
+{
+ _cairo_list_del (entry);
cairo_list_init (entry);
}
diff --git a/src/cairo-xlib-visual.c b/src/cairo-xlib-visual.c
index d9aac44..863822e 100644
--- a/src/cairo-xlib-visual.c
+++ b/src/cairo-xlib-visual.c
@@ -40,6 +40,7 @@
#include "cairo-xlib-private.h"
#include "cairo-error-private.h"
+#include "cairo-list-inline.h"
/* A perceptual distance metric between two colors. No sqrt needed
* since the square of the distance is still a valid metric. */
@@ -85,6 +86,7 @@ _cairo_xlib_visual_info_create (Display *dpy,
if (unlikely (info == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ cairo_list_init (&info->link);
info->visualid = visualid;
/* Allocate a gray ramp and a color cube.
@@ -185,6 +187,7 @@ void
_cairo_xlib_visual_info_destroy (cairo_xlib_visual_info_t *info)
{
/* No need for XFreeColors() whilst using DefaultColormap */
+ _cairo_list_del (&info->link);
free (info);
}
More information about the cairo-commit
mailing list