src: Fix memory issue reported by cppcheck static analysis tool

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>
This commit is contained in:
Ravi Nanjundappa 2014-08-21 18:18:34 +05:30 committed by Bryce Harrington
parent a5f51588af
commit 52c4f0f2da

View file

@ -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,