[epiphany] Handle invalid snapshot data



commit 73fb308bd9ffbb2ee6afbd0f5cb3c2443f1688f5
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Sun Aug 2 19:50:37 2020 +0200

    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

 lib/ephy-snapshot-service.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]