summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Michael Brummer <jan.brummer@tabos.org>2020-08-02 19:50:37 +0200
committerJan-Michael Brummer <jan.brummer@tabos.org>2020-08-15 11:18:25 +0200
commit73fb308bd9ffbb2ee6afbd0f5cb3c2443f1688f5 (patch)
tree0d8e7d8ac61cbbc255faa0481d02d75cd47f33f3
parente48a69233ea65770e2f46c727d96e479ac37d30e (diff)
downloadepiphany-73fb308bd9ffbb2ee6afbd0f5cb3c2443f1688f5.tar.gz
Handle invalid snapshot data
Instead of returning an error webkit returns a surface without data if the region is too large. Let's handle error those error cases and exit graceful. Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/1282
-rw-r--r--lib/ephy-snapshot-service.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ephy-snapshot-service.c b/lib/ephy-snapshot-service.c
index f027ebec7..55869ed82 100644
--- a/lib/ephy-snapshot-service.c
+++ b/lib/ephy-snapshot-service.c
@@ -220,6 +220,9 @@ ephy_snapshot_service_prepare_snapshot (cairo_surface_t *surface)
orig_width = cairo_image_surface_get_width (surface);
orig_height = cairo_image_surface_get_height (surface);
+ if (!orig_width || !orig_height)
+ return NULL;
+
if (orig_width < EPHY_THUMBNAIL_WIDTH ||
orig_height < EPHY_THUMBNAIL_HEIGHT) {
snapshot = gdk_pixbuf_get_from_surface (surface,
@@ -396,6 +399,14 @@ save_snapshot (cairo_surface_t *surface,
SnapshotAsyncData *data = g_task_get_task_data (task);
data->snapshot = ephy_snapshot_service_prepare_snapshot (surface);
+ if (!data->snapshot) {
+ g_task_return_new_error (task,
+ EPHY_SNAPSHOT_SERVICE_ERROR,
+ EPHY_SNAPSHOT_SERVICE_ERROR_WEB_VIEW,
+ "WebView returned invalid snapshot for \"%s\"", data->url);
+ g_object_unref (task);
+ return;
+ }
ephy_snapshot_service_save_snapshot_async (g_task_get_source_object (task),
data->snapshot,