mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
Plug some (possible) memleaks
PropGetWMClass() - XAllocClassHint()s a struct for class hint data - This is filled by XGetClassHint(), which in turn uses Xlib to allocate some more space for XClassHint members - Upon XGetClassHint() failure, "default" is libc malloc'd (via strdup), and is returned to the caller - Upon XGetClassHint() success, XClassHint members are returned raw -- these members must be freed with XFree() (see XAllocClassHint(3)) - Thus it's up to PropGetWMClass() callers to decide (based upon the return value) which method (libc free() or XFree()) to use to free res_name and res_class. This was done nowhere, thus leaking some memory on every failed PropGetWMClass() call. - So just strdup the successful res_name/res_class members, XFree() them while still in PropGetWMClass(), and allow callers to unconditionally libc free() whatever PropGetWMClass() returns.
This commit is contained in:
committed by
Carlos R. Mafra
parent
f6fefbd9b6
commit
dce16306bc
@@ -830,9 +830,9 @@ WWindow *wManageWindow(WScreen *scr, Window window)
|
||||
wwin->main_window = fPtr->leader;
|
||||
}
|
||||
if (instance)
|
||||
XFree(instance);
|
||||
free(instance);
|
||||
if (class)
|
||||
XFree(class);
|
||||
free(class);
|
||||
#undef ADEQUATE
|
||||
}
|
||||
|
||||
@@ -2654,9 +2654,9 @@ WMagicNumber wWindowGetSavedState(Window win)
|
||||
if (command)
|
||||
wfree(command);
|
||||
if (instance)
|
||||
XFree(instance);
|
||||
free(instance);
|
||||
if (class)
|
||||
XFree(class);
|
||||
free(class);
|
||||
|
||||
return wstate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user