fix memory leaks: free color description strings and icon paths
WMGetColorRGBDescription() returns wmalloc strings that were passed directly to allocFrameBorderPixel without freeing. get_default_image() and get_icon_image() leaked path strings from FindImage/get_icon_filename.
This commit is contained in:
parent
a6f43cdbe1
commit
b20197ac91
|
|
@ -400,9 +400,16 @@ void wFrameWindowUpdateBorders(WFrameWindow * fwin, int flags)
|
|||
|
||||
checkTitleSize(fwin);
|
||||
|
||||
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_border_color), &fwin->border_pixel);
|
||||
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_focused_border_color), &fwin->focused_border_pixel);
|
||||
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_selected_border_color), &fwin->selected_border_pixel);
|
||||
char *desc;
|
||||
desc = WMGetColorRGBDescription(scr->frame_border_color);
|
||||
allocFrameBorderPixel(fwin->colormap, desc, &fwin->border_pixel);
|
||||
wfree(desc);
|
||||
desc = WMGetColorRGBDescription(scr->frame_focused_border_color);
|
||||
allocFrameBorderPixel(fwin->colormap, desc, &fwin->focused_border_pixel);
|
||||
wfree(desc);
|
||||
desc = WMGetColorRGBDescription(scr->frame_selected_border_color);
|
||||
allocFrameBorderPixel(fwin->colormap, desc, &fwin->selected_border_pixel);
|
||||
wfree(desc);
|
||||
|
||||
if (flags & WFF_SELECTED) {
|
||||
if (fwin->selected_border_pixel)
|
||||
|
|
|
|||
|
|
@ -467,6 +467,8 @@ RImage *get_default_image(WScreen *scr)
|
|||
if (!image)
|
||||
wwarning(_("could not find default icon \"%s\""), path);
|
||||
|
||||
wfree(path);
|
||||
|
||||
/* Resize the icon to the wPreferences.icon_size size
|
||||
* usually this function will return early, because size is right */
|
||||
image = wIconValidateIconSize(image, wPreferences.icon_size);
|
||||
|
|
@ -481,7 +483,10 @@ RImage *get_icon_image(WScreen *scr, const char *winstance, const char *wclass,
|
|||
/* Get the file name of the image, using instance and class */
|
||||
file_name = get_icon_filename(winstance, wclass, NULL, True);
|
||||
|
||||
return get_rimage_from_file(scr, file_name, max_size);
|
||||
RImage *image = get_rimage_from_file(scr, file_name, max_size);
|
||||
if (file_name)
|
||||
wfree(file_name);
|
||||
return image;
|
||||
}
|
||||
|
||||
int wDefaultGetStartWorkspace(WScreen *scr, const char *instance, const char *class)
|
||||
|
|
|
|||
Loading…
Reference in New Issue