summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2018-08-27 18:20:37 +0200
committerGitHub <noreply@github.com>2018-08-27 18:20:37 +0200
commitd435849aec6c0ffa0e49b93f516502a86efd8dd4 (patch)
treeeaf5cbb1a29f5579ccf30f2ca9b791c05037fc00
parent57fa97773fc1f708fe572e8ed9fd9bf7a2c8f740 (diff)
downloadmidori-git-d435849aec6c0ffa0e49b93f516502a86efd8dd4.tar.gz
Check that the surface in load_icon is non-null (#18)
`WebKit.FaviconDatabase.get_favicon ()` can indeed return null without throwing an error.
-rw-r--r--core/favicon.vala8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/favicon.vala b/core/favicon.vala
index 0cd4593c..0fab681e 100644
--- a/core/favicon.vala
+++ b/core/favicon.vala
@@ -35,9 +35,11 @@ namespace Midori {
var database = WebKit.WebContext.get_default ().get_favicon_database ();
try {
var surface = yield database.get_favicon (uri, cancellable);
- var image = (Cairo.ImageSurface)surface;
- var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());
- gicon = (Icon)scale_to_icon_size (pixbuf);
+ if (surface != null) {
+ var image = (Cairo.ImageSurface)surface;
+ var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());
+ gicon = (Icon)scale_to_icon_size (pixbuf);
+ }
} catch (Error error) {
debug ("Icon failed to load: %s", error.message);
}