mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 12:00:31 +01:00
wmmenugen: Fix memory leaks when parsing menu in wmconfig format
As reported by Coverity (CID #50181, #50182 and #50183) the strings allocated by parse_wmconfig_line were not freed after use. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
f030ab7664
commit
0ac6827a9b
@@ -96,8 +96,10 @@ void parse_wmconfig(const char *file, cb_add_menu_entry *addWMMenuEntryCallback)
|
||||
|
||||
parse_wmconfig_line(&label, &key, &value, p);
|
||||
|
||||
if (label && strlen(label) == 0)
|
||||
if (label && strlen(label) == 0) {
|
||||
wfree(label);
|
||||
continue;
|
||||
}
|
||||
if (!lastlabel && label)
|
||||
lastlabel = wstrdup(label);
|
||||
|
||||
@@ -110,6 +112,7 @@ void parse_wmconfig(const char *file, cb_add_menu_entry *addWMMenuEntryCallback)
|
||||
wfree(lastlabel);
|
||||
lastlabel = wstrdup(label);
|
||||
}
|
||||
wfree(label);
|
||||
|
||||
if (key && value) {
|
||||
if (strcmp(key, "name") == 0)
|
||||
@@ -124,10 +127,13 @@ void parse_wmconfig(const char *file, cb_add_menu_entry *addWMMenuEntryCallback)
|
||||
wmc->Flags |= F_TERMINAL;
|
||||
}
|
||||
|
||||
wfree(key);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
wfree(lastlabel);
|
||||
|
||||
if (wmc_to_wm(&wmc, &wm)) {
|
||||
(*addWMMenuEntryCallback)(wm);
|
||||
init_wmconfig_storage(&wmc);
|
||||
|
||||
Reference in New Issue
Block a user