Fix memory leak in xf_window.c. If property lookup for current desktop failed, we leaked property memory for workspace attributes. Added check in case returned desktop number is greater than number of workspaces.

This commit is contained in:
David Sundstrom 2011-11-01 14:31:57 -05:00
parent a4ddc4c685
commit 7a51d0300a
1 changed files with 10 additions and 4 deletions

View File

@ -118,8 +118,9 @@ boolean xf_GetCurrentDesktop(xfInfo* xfi)
status = xf_GetWindowProperty(xfi, DefaultRootWindow(xfi->display),
xfi->_NET_CURRENT_DESKTOP, 1, &nitems, &bytes, &prop);
if (status != True)
if (status != True) {
return False;
}
xfi->current_desktop = (int) *prop;
xfree(prop);
@ -135,16 +136,21 @@ boolean xf_GetWorkArea(xfInfo* xfi)
unsigned long bytes;
unsigned char* prop;
status = xf_GetCurrentDesktop(xfi);
if (status != True)
return False;
status = xf_GetWindowProperty(xfi, DefaultRootWindow(xfi->display),
xfi->_NET_WORKAREA, 32 * 4, &nitems, &bytes, &prop);
if (status != True)
return False;
status = xf_GetCurrentDesktop(xfi);
if (status != True)
if ((xfi->current_desktop * 4 + 3) >= nitems) {
xfree(prop);
return False;
}
plong = (long*) prop;