mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-31 19:12:32 +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:
committed by
Carlos R. Mafra
parent
5dcd31acbe
commit
7746fe7c5a
11
src/icon.c
11
src/icon.c
@@ -584,11 +584,15 @@ void wIconSelect(WIcon * icon)
|
|||||||
|
|
||||||
static void unset_icon_image(WIcon *icon)
|
static void unset_icon_image(WIcon *icon)
|
||||||
{
|
{
|
||||||
if (icon->file)
|
if (icon->file) {
|
||||||
wfree(icon->file);
|
wfree(icon->file);
|
||||||
|
icon->file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (icon->file_image)
|
if (icon->file_image) {
|
||||||
RReleaseImage(icon->file_image);
|
RReleaseImage(icon->file_image);
|
||||||
|
icon->file_image = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wIconUpdate(WIcon *icon)
|
void wIconUpdate(WIcon *icon)
|
||||||
@@ -755,8 +759,7 @@ static int get_rimage_icon_from_wm_hints(WIcon *icon)
|
|||||||
if (!image)
|
if (!image)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* FIXME: If unset_icon_image, pointer double free then crash
|
unset_icon_image(icon);
|
||||||
unset_icon_image(icon); */
|
|
||||||
icon->file_image = image;
|
icon->file_image = image;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user