From baecab089c053fa070ce962e02e599dd868dd4e5 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Tue, 9 Oct 2012 00:20:44 +0200 Subject: [PATCH] Fixed crash when changing icon to non-existent file As found by Rodolfo, a crash could happen when changing an icon to a non-existent file. From his report: Steps To Reproduce 1. Open the Settings box, for example for WMDock. (Right click on WMDock, Settings). 2. In the "Icon Image" field, write some characters. For example "asdfasdfasd". 3. Click in "OK". You get "Could not open specified icon file: GNUstep.tiffasdfasdfasd" 4. Hit in "OK" 5. Repeat 2,3,4 some times (sometimes 1, sometimes 2, sometimes 10). The problem came from freeing the previous icon but not updating the pointer, so if the new file did not exist it ended up with a fake-looking icon being used, hence possible crash. BTS: http://www.kix.es/mantis/view.php?id=1 --- src/icon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/icon.c b/src/icon.c index e950a7d6..0370d71b 100644 --- a/src/icon.c +++ b/src/icon.c @@ -369,11 +369,12 @@ Bool wIconChangeImageFile(WIcon * icon, char *file) char *path; int error = 0; - if (icon->file_image) + if (icon->file_image) { RReleaseImage(icon->file_image); + icon->file_image = NULL; + } if (!file) { - icon->file_image = NULL; wIconUpdate(icon); return True; } -- 2.11.4.GIT