From 7746fe7c5a46a58eb5a2e5393487de8213bb0a42 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Wed, 14 Nov 2012 21:23:32 +0100 Subject: [PATCH] Added reset of pointer after memory free to avoid double-free crash As reported by Rodolfo, there are some cases when working with icons where a crash can occur, which is related to trying to re-release some memory that have been already freed previously. This patch adds a reset-to-NULL of the corresponding pointers so that on next usage wmaker will know there's no more memory associated with these pointers. --- src/icon.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/icon.c b/src/icon.c index ba059ade..04767d8c 100644 --- a/src/icon.c +++ b/src/icon.c @@ -584,11 +584,15 @@ void wIconSelect(WIcon * icon) static void unset_icon_image(WIcon *icon) { - if (icon->file) + if (icon->file) { wfree(icon->file); + icon->file = NULL; + } - if (icon->file_image) + if (icon->file_image) { RReleaseImage(icon->file_image); + icon->file_image = NULL; + } } void wIconUpdate(WIcon *icon) @@ -755,8 +759,7 @@ static int get_rimage_icon_from_wm_hints(WIcon *icon) if (!image) return 1; - /* FIXME: If unset_icon_image, pointer double free then crash - unset_icon_image(icon); */ + unset_icon_image(icon); icon->file_image = image; return 0; -- 2.11.4.GIT