Skip to content

Commit

Permalink
Fix a 21 byte memory leak.
Browse files Browse the repository at this point in the history
merge_styles allocated a small amount of memory using strdup(). This
memory wasn't being freed by the callers. I had to change
do_free_src_and_alloc_copy argument of merge_styles to True in
lookup_style() to get free_style() to stop crashing.

Fixes fvwmorg#430.
  • Loading branch information
Quipyowert2 committed Feb 14, 2021
1 parent 4405437 commit de85177
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions fvwm/add_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,7 @@ int setup_visible_names(FvwmWindow *fw, int what_changed)
free(ext_name);
}
}
free_style(&style);

return (changed_styles) ? changed_styles : affected_titles;
}
Expand Down Expand Up @@ -2358,6 +2359,7 @@ FvwmWindow *AddWindow(
}
free(fw);
MyXUngrabServer(dpy);
free_style(&style);
return NULL;
}

Expand Down Expand Up @@ -2389,6 +2391,7 @@ FvwmWindow *AddWindow(
}
free(fw);
MyXUngrabServer(dpy);
free_style(&style);
return AW_UNMANAGED;
}

Expand Down Expand Up @@ -2807,6 +2810,7 @@ FvwmWindow *AddWindow(
destroy_window(fw);
fw = NULL;
}
free_style(&style);

return fw;
}
Expand Down
1 change: 1 addition & 0 deletions fvwm/placement.c
Original file line number Diff line number Diff line change
Expand Up @@ -2426,6 +2426,7 @@ void CMD_PlaceAgain(F_CMD_ARGS)
AnimatedMoveFvwmWindow(
fw, FW_W_FRAME(fw), -1, -1, attr_g.x, attr_g.y, False,
-1, ppctMovement);
free_style(&style);
}
if (fw->Desk != old_desk)
{
Expand Down
4 changes: 2 additions & 2 deletions fvwm/style.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ static void merge_styles(
return;
}

static void free_style(window_style *style)
void free_style(window_style *style)
{
/* Free contents of style */
SAFEFREE(SGET_NAME(*style));
Expand Down Expand Up @@ -4764,7 +4764,7 @@ void lookup_style(FvwmWindow *fw, window_style *styles)
{
if (fw_match_style_id(fw, SGET_ID(*nptr)))
{
merge_styles(styles, nptr, False);
merge_styles(styles, nptr, True);
}
}
EWMH_GetStyle(fw, styles);
Expand Down
1 change: 1 addition & 0 deletions fvwm/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,5 +676,6 @@ void update_icon_background_cs_style(FvwmWindow *fw, window_style *pstyle);
void free_icon_boxes(icon_boxes *ib);
void style_destroy_style(style_id_t s_id);
void print_styles(int verbose);
void free_style(window_style *style);

#endif /* FVWM_STYLE_H */
2 changes: 2 additions & 0 deletions fvwm/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ void apply_decor_change(FvwmWindow *fw)
flags.do_redecorate = True;
flags.do_update_window_font_height = True;
apply_window_updates(fw, &flags, &style, get_focus_window());
free_style(&style);

return;
}
Expand Down Expand Up @@ -725,6 +726,7 @@ void flush_window_updates(void)
}
/* now apply the changes */
apply_window_updates(t, &flags, &style, focus_fw);
free_style(&style);
}

/* restore the focus; also handles the case that the previously focused
Expand Down
1 change: 1 addition & 0 deletions fvwm/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -2699,6 +2699,7 @@ desk_get_fw_count(struct monitor *m, int desk)
if (SIS_UNMANAGED(sflags))
continue;
count++;
free_style(&style);
}
}
}
Expand Down

0 comments on commit de85177

Please sign in to comment.