image: Don't segfault when the file doesn't exist
authorJuan Zhao <juan.j.zhao@linux.intel.com>
Tue, 7 Aug 2012 02:45:43 +0000 (19:45 -0700)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 9 Aug 2012 14:55:40 +0000 (10:55 -0400)
Don't create a window when the file doesn't exist.

https://bugs.freedesktop.org/show_bug.cgi?id=52450

clients/image.c

index 711f0d8..c289d76 100644 (file)
@@ -130,6 +130,12 @@ image_create(struct display *display, const char *filename)
 
        image->filename = strdup(filename);
        image->image = load_cairo_surface(filename);
+
+       if (!image->image) {
+               fprintf(stderr, "could not find the image %s!\n", b);
+               return NULL;
+       }
+
        image->window = window_create(display);
        image->widget = frame_create(image->window, image);
        window_set_title(image->window, title);