mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +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);
|
parse_wmconfig_line(&label, &key, &value, p);
|
||||||
|
|
||||||
if (label && strlen(label) == 0)
|
if (label && strlen(label) == 0) {
|
||||||
|
wfree(label);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (!lastlabel && label)
|
if (!lastlabel && label)
|
||||||
lastlabel = wstrdup(label);
|
lastlabel = wstrdup(label);
|
||||||
|
|
||||||
@@ -110,6 +112,7 @@ void parse_wmconfig(const char *file, cb_add_menu_entry *addWMMenuEntryCallback)
|
|||||||
wfree(lastlabel);
|
wfree(lastlabel);
|
||||||
lastlabel = wstrdup(label);
|
lastlabel = wstrdup(label);
|
||||||
}
|
}
|
||||||
|
wfree(label);
|
||||||
|
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
if (strcmp(key, "name") == 0)
|
if (strcmp(key, "name") == 0)
|
||||||
@@ -124,10 +127,13 @@ void parse_wmconfig(const char *file, cb_add_menu_entry *addWMMenuEntryCallback)
|
|||||||
wmc->Flags |= F_TERMINAL;
|
wmc->Flags |= F_TERMINAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wfree(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
|
wfree(lastlabel);
|
||||||
|
|
||||||
if (wmc_to_wm(&wmc, &wm)) {
|
if (wmc_to_wm(&wmc, &wm)) {
|
||||||
(*addWMMenuEntryCallback)(wm);
|
(*addWMMenuEntryCallback)(wm);
|
||||||
init_wmconfig_storage(&wmc);
|
init_wmconfig_storage(&wmc);
|
||||||
|
|||||||
Reference in New Issue
Block a user