summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-12-05 14:42:15 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-12-05 17:17:26 +0000
commitd7dcf9d28fdf05c8acabd8ed3dc25e0cf279e61e (patch)
tree216e8a6f08a898b6ad2bbd10240a779a5cdee71d
parent3edf369eade8b587aeaa162bd3bbeb3546c35b84 (diff)
gl: Check against user-provided invalid sizes
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/cairo-egl-context.c3
-rw-r--r--src/cairo-glx-context.c3
-rw-r--r--src/cairo-wgl-context.c3
3 files changed, 9 insertions, 0 deletions
diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c
index ec238526..00bfcbf9 100644
--- a/src/cairo-egl-context.c
+++ b/src/cairo-egl-context.c
@@ -218,6 +218,9 @@ cairo_gl_surface_create_for_egl (cairo_device_t *device,
if (device->backend->type != CAIRO_DEVICE_TYPE_GL)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+ if (width <= 0 || height <= 0)
+ return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
+
surface = calloc (1, sizeof (cairo_egl_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-glx-context.c b/src/cairo-glx-context.c
index f89fa32c..512bee8d 100644
--- a/src/cairo-glx-context.c
+++ b/src/cairo-glx-context.c
@@ -265,6 +265,9 @@ cairo_gl_surface_create_for_window (cairo_device_t *device,
if (device->backend->type != CAIRO_DEVICE_TYPE_GL)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+ if (width <= 0 || height <= 0)
+ return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
+
surface = calloc (1, sizeof (cairo_glx_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-wgl-context.c b/src/cairo-wgl-context.c
index 82f12110..48723744 100644
--- a/src/cairo-wgl-context.c
+++ b/src/cairo-wgl-context.c
@@ -246,6 +246,9 @@ cairo_gl_surface_create_for_dc (cairo_device_t *device,
if (device->backend->type != CAIRO_DEVICE_TYPE_GL)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+ if (width <= 0 || height <= 0)
+ return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
+
surface = calloc (1, sizeof (cairo_wgl_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));