[gthumb] SEGFAULT when a svg image could not be loaded
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] SEGFAULT when a svg image could not be loaded
- Date: Fri, 14 Jul 2017 07:00:23 +0000 (UTC)
commit 76dfe697763ffdce69821fae84d04660d17d4bdb
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Jul 14 08:47:13 2017 +0200
SEGFAULT when a svg image could not be loaded
[bug 784886]
extensions/cairo_io/cairo-image-surface-svg.c | 18 +++++++++++++-----
gthumb/gth-image-viewer.c | 5 ++++-
2 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/extensions/cairo_io/cairo-image-surface-svg.c b/extensions/cairo_io/cairo-image-surface-svg.c
index ee07770..75e6f48 100644
--- a/extensions/cairo_io/cairo-image-surface-svg.c
+++ b/extensions/cairo_io/cairo-image-surface-svg.c
@@ -140,22 +140,26 @@ gth_image_svg_new (void)
}
-static void
+static gboolean
gth_image_svg_set_handle (GthImageSvg *self,
RsvgHandle *rsvg)
{
RsvgDimensionData dimension_data;
if (self->rsvg == rsvg)
- return;
+ return TRUE;
- self->rsvg = g_object_ref (rsvg);
+ rsvg_handle_get_dimensions (rsvg, &dimension_data);
+ if ((dimension_data.width == 0) || (dimension_data.height == 0))
+ return FALSE;
- rsvg_handle_get_dimensions (self->rsvg, &dimension_data);
+ self->rsvg = g_object_ref (rsvg);
self->original_width = dimension_data.width;
self->original_height = dimension_data.height;
gth_image_svg_set_zoom (GTH_IMAGE (self), 1.0, NULL, NULL);
+
+ return TRUE;
}
@@ -183,7 +187,11 @@ _cairo_image_surface_create_from_svg (GInputStream *istream,
cancellable,
error);
if (rsvg != NULL) {
- gth_image_svg_set_handle (GTH_IMAGE_SVG (image), rsvg);
+ if (! gth_image_svg_set_handle (GTH_IMAGE_SVG (image), rsvg)) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "Error");
+ g_object_unref (image);
+ image = NULL;
+ }
g_object_unref (rsvg);
}
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index ca3199b..ee95894 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -815,7 +815,10 @@ image_has_alpha (GthImageViewer *viewer)
if (image == NULL)
return FALSE;
- first_pixel = cairo_image_surface_get_data (image);
+ first_pixel = _cairo_image_surface_flush_and_get_data (image);
+ if (first_pixel == NULL)
+ return FALSE;
+
return first_pixel[CAIRO_ALPHA] < 255;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]