On Sat, 17 Nov 2012, Rodolfo García Peñas wrote:
The variable wwin is only used in one block of the if, so should be moved
inside this block. OTOH, is better check if the variabl exists before
assign it. The code now is more stable and avoid crashes.
You are right but...
diff --git a/src/icon.c b/src/icon.c
index ddcf167..de766ad 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -601,11 +601,14 @@ static void unset_icon_image(WIcon *icon)
void wIconUpdate(WIcon *icon, RImage *image)
{
- WWindow *wwin = icon->owner;
+ WWindow *wwin = NULL;
if (image) {
icon->file_image = image;
^^
..if icon is NULL it may crash here. Apparently it is invalid to call
this function without icon being non-NULL so maybe instead of checking for
it at every place you could just put an assert(icon != NULL) at the
beginning (or if (!icon) return; if that's what should happen instead).
} else {
+ if (icon && icon->owner)
+ wwin = icon->owner;
+
if (wwin && WFLAGP(wwin, always_user_icon)) {
/* Forced use user_icon */
get_rimage_icon_from_user_icon(icon);