1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-26 08:22:37 +01:00

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.
This commit is contained in:
Christophe CURIS
2012-11-14 21:23:32 +01:00
committed by Carlos R. Mafra
parent 5dcd31acbe
commit 7746fe7c5a

View File

@@ -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;