1
0
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:
Christophe CURIS
2021-05-16 15:47:14 +02:00
committed by Carlos R. Mafra
parent f030ab7664
commit 0ac6827a9b

View File

@@ -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);