summaryrefslogtreecommitdiffhomepage
path: root/lib/uci.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2023-10-11 16:53:42 +0200
committerJo-Philipp Wich <jo@mein.io>2023-10-11 16:55:14 +0200
commit9993ccb2ee31db072cb3519bd160b149ace929ad (patch)
tree9b07f8494e546177e2fecfd66cd0acb01d0e1649 /lib/uci.c
parent2b2a47240c089a2cb10223efd4a1f133638f5dd5 (diff)
uci: fix potential memory leaks in `configs()`
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 <jo@mein.io>
Diffstat (limited to 'lib/uci.c')
-rw-r--r--lib/uci.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/uci.c b/lib/uci.c
index 96cce6a..7868824 100644
--- a/lib/uci.c
+++ b/lib/uci.c
@@ -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])))