[cairo-commit] 2 commits - src/cairo-cogl-surface.c src/cairo-qt-surface.cpp src/cairo-quartz-image-surface.c src/drm src/win32

Bryce Harrington bryce at kemper.freedesktop.org
Tue Sep 23 11:00:56 PDT 2014


 src/cairo-cogl-surface.c         |    2 +-
 src/cairo-qt-surface.cpp         |    2 +-
 src/cairo-quartz-image-surface.c |    2 +-
 src/drm/cairo-drm.c              |    9 ++++++---
 src/win32/cairo-win32-surface.c  |    2 +-
 5 files changed, 10 insertions(+), 7 deletions(-)

New commits:
commit a02e29a12d82f177bdf99ed8cfd0c3b3b78c44da
Author: Bryce Harrington <bryce at osg.samsung.com>
Date:   Mon Sep 22 15:48:49 2014 -0700

    Don't return NULL to clients when getting device
    
    Return an error device instead
    
    Fixes:  https://bugs.freedesktop.org/show_bug.cgi?id=58061

diff --git a/src/cairo-cogl-surface.c b/src/cairo-cogl-surface.c
index 7389c3e..c57fd7f 100644
--- a/src/cairo-cogl-surface.c
+++ b/src/cairo-cogl-surface.c
@@ -2789,7 +2789,7 @@ cairo_cogl_device_create (CoglContext *cogl_context)
 
 ERROR:
     g_free (dev);
-    return NULL;
+    return _cairo_device_create_in_error (CAIRO_STATUS_DEVICE_ERROR);
 }
 slim_hidden_def (cairo_cogl_device_create);
 
diff --git a/src/drm/cairo-drm.c b/src/drm/cairo-drm.c
index 051b79e..661e181 100644
--- a/src/drm/cairo-drm.c
+++ b/src/drm/cairo-drm.c
@@ -202,8 +202,7 @@ cairo_drm_device_get (struct udev_device *device)
     parent = udev_device_get_parent (device);
     pci_id = get_udev_property (parent, "PCI_ID");
     if (pci_id == NULL || sscanf (pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
-	dev = (cairo_drm_device_t *)
-	    _cairo_device_create_in_error (CAIRO_STATUS_DEVICE_ERROR);
+        dev = NULL;
 	goto DONE;
     }
 
@@ -239,6 +238,7 @@ cairo_drm_device_get (struct udev_device *device)
     if (fd == -1) {
 	/* XXX more likely to be a permissions issue... */
 	_cairo_error_throw (CAIRO_STATUS_FILE_NOT_FOUND);
+	dev = NULL;
 	goto DONE;
     }
 
@@ -249,7 +249,10 @@ cairo_drm_device_get (struct udev_device *device)
   DONE:
     CAIRO_MUTEX_UNLOCK (_cairo_drm_device_mutex);
 
-    return &dev->base;
+    if (dev == NULL)
+        return _cairo_device_create_in_error (CAIRO_STATUS_DEVICE_ERROR);
+    else
+        return &dev->base;
 }
 slim_hidden_def (cairo_drm_device_get);
 
commit 150c1e7044c57443d458e12bfc427d3a019cb60b
Author: Bryce Harrington <bryce at osg.samsung.com>
Date:   Mon Sep 22 15:41:24 2014 -0700

    Don't return NULL to clients when getting image
    
    Return an error surface instead.
    
    Fixes:  https://bugs.freedesktop.org/show_bug.cgi?id=58061

diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp
index 8a91984..d1c7760 100644
--- a/src/cairo-qt-surface.cpp
+++ b/src/cairo-qt-surface.cpp
@@ -1688,7 +1688,7 @@ cairo_qt_surface_get_image (cairo_surface_t *surface)
     cairo_qt_surface_t *qs = (cairo_qt_surface_t*) surface;
 
     if (surface->type != CAIRO_SURFACE_TYPE_QT)
-        return NULL;
+        return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
 
     return qs->image_equiv;
 }
diff --git a/src/cairo-quartz-image-surface.c b/src/cairo-quartz-image-surface.c
index 2715abd..511b634 100644
--- a/src/cairo-quartz-image-surface.c
+++ b/src/cairo-quartz-image-surface.c
@@ -379,7 +379,7 @@ cairo_quartz_image_surface_get_image (cairo_surface_t *asurface)
     cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t*) asurface;
 
     if (asurface->type != CAIRO_SURFACE_TYPE_QUARTZ_IMAGE)
-	return NULL;
+        return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
 
     return (cairo_surface_t*) surface->imageSurface;
 }
diff --git a/src/win32/cairo-win32-surface.c b/src/win32/cairo-win32-surface.c
index 7cd46fc..f11cbd8 100644
--- a/src/win32/cairo-win32-surface.c
+++ b/src/win32/cairo-win32-surface.c
@@ -188,7 +188,7 @@ cairo_surface_t *
 cairo_win32_surface_get_image (cairo_surface_t *surface)
 {
     if (surface->backend->type != CAIRO_SURFACE_TYPE_WIN32)
-	return NULL;
+        return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
 
     GdiFlush();
     return to_win32_display_surface(surface)->image;


More information about the cairo-commit mailing list