summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce Harrington <bryce@bryceharrington.org>2018-06-06 11:06:18 -0700
committerBryce Harrington <bryce@bryceharrington.org>2018-06-13 15:21:50 -0700
commit1c3ecfac133e5f284934fef9af988405e24347da (patch)
treef5a92b5cc3952896655b68d1bf530e06cf11df01
parent37655af38d320336fe00894dbc2e47d16ea58497 (diff)
snapshot: Don't use extra after it's been freed (CID #220086)
Note this changes the semantics of the value of extra_out such that it is set to NULL instead of left undefined in case an error is returned. Coverity ID: 220086 Signed-off-by: Bryce Harrington <bryce@bryceharrington.org> Reviewed-By: Uli Schlachter <psychon@znc.in>
-rw-r--r--src/cairo-surface-snapshot.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cairo-surface-snapshot.c b/src/cairo-surface-snapshot.c
index c8f307843..a8b8c0e45 100644
--- a/src/cairo-surface-snapshot.c
+++ b/src/cairo-surface-snapshot.c
@@ -100,14 +100,17 @@ _cairo_surface_snapshot_acquire_source_image (void *abstract_
cairo_status_t status;
extra = _cairo_malloc (sizeof (*extra));
- if (unlikely (extra == NULL))
+ if (unlikely (extra == NULL)) {
+ *extra_out = NULL;
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ }
extra->target = _cairo_surface_snapshot_get_target (&surface->base);
status = _cairo_surface_acquire_source_image (extra->target, image_out, &extra->extra);
if (unlikely (status)) {
cairo_surface_destroy (extra->target);
free (extra);
+ extra = NULL;
}
*extra_out = extra;