[PATCH 2/2] xlib-xcb/xcb: Check for right device in [gs]et_precision

Uli Schlachter psychon at znc.in
Sun Jul 3 08:52:42 PDT 2011


Signed-off-by: Uli Schlachter <psychon at znc.in>
---
 src/cairo-xcb-connection.c   |   16 ++++++++++++++--
 src/cairo-xlib-xcb-surface.c |   18 ++++++++++++++++++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index de1bb17..d6ec679 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -905,8 +905,14 @@ void
 cairo_xcb_device_debug_set_precision (cairo_device_t *device,
 				      int precision)
 {
+    cairo_status_t status;
+
     if (device->status)
-	    return;
+	return;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XCB) {
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	return;
+    }
 
     ((cairo_xcb_connection_t *) device)->force_precision = precision;
 }
@@ -917,8 +923,14 @@ slim_hidden_def (cairo_xcb_device_debug_set_precision);
 int
 cairo_xcb_device_debug_get_precision (cairo_device_t *device)
 {
+    cairo_status_t status;
+
     if (device->status)
-	    return -1;
+	return -1;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XCB) {
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	return -1;
+    }
 
     return ((cairo_xcb_connection_t *) device)->force_precision;
 }
diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c
index 1d1a45b..037b519 100644
--- a/src/cairo-xlib-xcb-surface.c
+++ b/src/cairo-xlib-xcb-surface.c
@@ -740,6 +740,15 @@ cairo_xlib_device_debug_set_precision (cairo_device_t *device,
 				       int precision)
 {
     cairo_xlib_xcb_display_t *display = (cairo_xlib_xcb_display_t *) device;
+    cairo_status_t status;
+
+    if (device->status)
+	return;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XLIB) {
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	return;
+    }
+
     cairo_xcb_device_debug_set_precision (display->xcb_device, precision);
 }
 
@@ -747,6 +756,15 @@ int
 cairo_xlib_device_debug_get_precision (cairo_device_t *device)
 {
     cairo_xlib_xcb_display_t *display = (cairo_xlib_xcb_display_t *) device;
+    cairo_status_t status;
+
+    if (device->status)
+	return -1;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XLIB) {
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	return -1;
+    }
+
     return cairo_xcb_device_debug_get_precision (display->xcb_device);
 }
 
-- 
1.7.5.4


--------------030606010808080108020706--


More information about the cairo mailing list