]> granicus.if.org Git - imagemagick/commitdiff
Proper fix for #875.
authorDirk Lemstra <dirk@git.imagemagick.org>
Thu, 23 Nov 2017 22:31:16 +0000 (23:31 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Thu, 23 Nov 2017 22:31:16 +0000 (23:31 +0100)
coders/svg.c

index 69faeaaa7f5449584e7c46806b23125a15f29fe4..c3e73415c73abe7968ec46f3c74489b974507f94 100644 (file)
@@ -3081,8 +3081,11 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
             cairo_surface=cairo_image_surface_create_for_data(pixels,
               CAIRO_FORMAT_ARGB32,(int) image->columns,(int) image->rows,(int)
               stride);
-            if (cairo_surface_status() != CAIRO_STATUS_SUCCESS)
+            if ((cairo_surface == (cairo_surface_t *) NULL) ||
+                (cairo_surface_status(cairo_surface) != CAIRO_STATUS_SUCCESS))
               {
+                if (cairo_surface != (cairo_surface_t *) NULL)
+                  cairo_surface_destroy(cairo_surface);
                 pixel_info=RelinquishVirtualMemory(pixel_info);
                 g_object_unref(svg_handle);
                 ThrowReaderException(ResourceLimitError,