[PATCH] fix a small bug for null image

juan.j.zhao at linux.intel.com juan.j.zhao at linux.intel.com
Fri Dec 30 12:21:27 PST 2011


From: Juan Zhao <juan.j.zhao at linux.intel.com>

if the image file is not found, desktop-shell will exit un-expectly
add the error checking in background_draw
---
 clients/desktop-shell.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 87053f6..14baa48 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -325,6 +325,8 @@ background_draw(struct window *window, int width, int height, const char *path)
 
 	if (path) {
 		image = load_jpeg(path);
+		if(!image)
+			goto err_path;
 		pattern = cairo_pattern_create_for_surface(image);
 		sx = (double) cairo_image_surface_get_width(image) / width;
 		sy = (double) cairo_image_surface_get_height(image) / height;
@@ -336,6 +338,7 @@ background_draw(struct window *window, int width, int height, const char *path)
 		cairo_surface_destroy(image);
 	}
 
+err_path:
 	cairo_destroy(cr);
 	cairo_surface_destroy(surface);
 	window_flush(window);
-- 
1.7.2.2



More information about the wayland-devel mailing list