[PATCH 2/2] Don't return NULL to clients when getting device
Bryce Harrington <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
Return an error device instead Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=58061 Signed-off-by: Bryce Harrington <[email protected]> --- src/cairo-cogl-surface.c | 2 +- src/drm/cairo-drm.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) 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); -- 1.7.9.5 -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo