mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-08 14:54:13 +01:00
WMaker: fix memory leak in windows menu (Coverity #50109)
As pointed by Coverity, there was a memory leak when updating the shortcuts in the menu for windows which occured when a shortcut was associated with the window and this shortcut did not change. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
7f840db1aa
commit
43972d307a
@@ -361,7 +361,6 @@ static void updateMakeShortcutMenu(WMenu *menu, WWindow *wwin)
|
|||||||
buffer = wmalloc(buflen);
|
buffer = wmalloc(buflen);
|
||||||
|
|
||||||
for (i = WO_ENTRIES; i < smenu->entry_no; i++) {
|
for (i = WO_ENTRIES; i < smenu->entry_no; i++) {
|
||||||
char *tmp;
|
|
||||||
int shortcutNo = i - WO_ENTRIES;
|
int shortcutNo = i - WO_ENTRIES;
|
||||||
WMenuEntry *entry = smenu->entries[i];
|
WMenuEntry *entry = smenu->entries[i];
|
||||||
WMArray *shortSelWindows = w_global.shortcut.windows[shortcutNo];
|
WMArray *shortSelWindows = w_global.shortcut.windows[shortcutNo];
|
||||||
@@ -387,12 +386,28 @@ static void updateMakeShortcutMenu(WMenu *menu, WWindow *wwin)
|
|||||||
kcode = wKeyBindings[WKBD_WINDOW1 + shortcutNo].keycode;
|
kcode = wKeyBindings[WKBD_WINDOW1 + shortcutNo].keycode;
|
||||||
|
|
||||||
if (kcode) {
|
if (kcode) {
|
||||||
if ((tmp = GetShortcutKey(wKeyBindings[WKBD_WINDOW1 + shortcutNo]))
|
char *tmp;
|
||||||
&& (!entry->rtext || strcmp(tmp, entry->rtext) != 0)) {
|
|
||||||
if (entry->rtext)
|
tmp = GetShortcutKey(wKeyBindings[WKBD_WINDOW1 + shortcutNo]);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
if (entry->rtext != NULL) {
|
||||||
|
/* There was a shortcut, but there is no more */
|
||||||
wfree(entry->rtext);
|
wfree(entry->rtext);
|
||||||
|
entry->rtext = NULL;
|
||||||
|
smenu->flags.realized = 0;
|
||||||
|
}
|
||||||
|
} else if (entry->rtext == NULL) {
|
||||||
|
/* There was no shortcut, but there is one now */
|
||||||
entry->rtext = tmp;
|
entry->rtext = tmp;
|
||||||
smenu->flags.realized = 0;
|
smenu->flags.realized = 0;
|
||||||
|
} else if (strcmp(tmp, entry->rtext) != 0) {
|
||||||
|
/* There was a shortcut, but it has changed */
|
||||||
|
wfree(entry->rtext);
|
||||||
|
entry->rtext = tmp;
|
||||||
|
smenu->flags.realized = 0;
|
||||||
|
} else {
|
||||||
|
/* There was a shortcut but it did not change */
|
||||||
|
wfree(tmp);
|
||||||
}
|
}
|
||||||
wMenuSetEnabled(smenu, i, True);
|
wMenuSetEnabled(smenu, i, True);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user