Skip to content

Commit

Permalink
uci: fix potential memory leaks in configs()
Browse files Browse the repository at this point in the history
In case `uci.cursor.configs()` is invoked with a completely empty
configuration directory, the empty configuration list is not free
before returning the `UCI_ERR_NOTFOUND` status.

Signed-off-by: Jo-Philipp Wich <[email protected]>
  • Loading branch information
jow- committed Oct 11, 2023
1 parent 2b2a472 commit 9993ccb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/uci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,8 +1385,10 @@ uc_uci_pkg_command(uc_vm_t *vm, size_t nargs, enum pkg_cmd cmd)
if (uci_list_configs(*c, &configs))
err_return((*c)->err);

if (!configs || !configs[0])
if (!configs || !configs[0]) {
free(configs);
err_return(UCI_ERR_NOTFOUND);
}

for (i = 0; configs[i]; i++) {
if (!(p = uci_lookup_package(*c, configs[i])))
Expand Down

0 comments on commit 9993ccb

Please sign in to comment.