Skip to content

Commit

Permalink
src: Fix memory issue reported by cppcheck static analysis tool
Browse files Browse the repository at this point in the history
cppcheck analysis tool reports the following issues when run on the
latest Cairo source.

$ grep "(error)"  cppcheck_error_log.txt
[src/skia/cairo-skia-surface.cpp:245]: (error) Memory leak: surface
$

The proposed changes fixes the above issues.

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
  • Loading branch information
Ravi Nanjundappa authored and Bryce Harrington committed Aug 28, 2014
1 parent a5f5158 commit 52c4f0f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/skia/cairo-skia-surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ _cairo_skia_surface_create_internal (SkBitmap::Config config,
pixman_image = pixman_image_create_bits (pixman_format,
width, height,
(uint32_t *) data, stride);
if (unlikely (pixman_image == NULL))
if (unlikely (pixman_image == NULL)) {
free (surface);
return (cairo_skia_surface_t *) _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
}

_cairo_surface_init (&surface->image.base,
&cairo_skia_surface_backend,
Expand Down

0 comments on commit 52c4f0f

Please sign in to comment.