diff options
author | Yousong Zhou <yszhou4tech@gmail.com> | 2014-12-16 15:00:04 +0800 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-12-18 12:38:15 +0100 |
commit | ecf0ed555ebc1b8e5b6aba54bb06a907bb4aecf2 (patch) | |
tree | 4e9b4314a2e1919adee1bede6bfccec942a72928 | |
parent | 9167f11f002725cc82c4995601d3220813cb1e62 (diff) | |
download | uci-ecf0ed555ebc1b8e5b6aba54bb06a907bb4aecf2.tar.gz |
Fix memory leaks found by using valgrind on test cases.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r-- | cli.c | 8 | ||||
-rw-r--r-- | list.c | 2 |
2 files changed, 7 insertions, 3 deletions
@@ -360,6 +360,7 @@ static int uci_do_package_cmd(int cmd, int argc, char **argv) { char **configs = NULL; char **p; + int ret = 1; if (argc > 2) return 255; @@ -369,14 +370,17 @@ static int uci_do_package_cmd(int cmd, int argc, char **argv) if ((uci_list_configs(ctx, &configs) != UCI_OK) || !configs) { cli_perror(); - return 1; + goto out; } for (p = configs; *p; p++) { package_cmd(cmd, *p); } - return 0; + ret = 0; +out: + free(configs); + return ret; } static int uci_do_add(int argc, char **argv) @@ -346,7 +346,7 @@ uci_lookup_ext_section(struct uci_context *ctx, struct uci_ptr *ptr) goto done; error: - e = NULL; + free(section); memset(ptr, 0, sizeof(struct uci_ptr)); UCI_THROW(ctx, UCI_ERR_INVAL); done: |