diff options
author | Justin Bronder <jsbronder@brontes3d.com> | 2009-12-01 11:13:41 -0500 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2009-12-01 19:15:57 +0100 |
commit | aa3ab8012bfbf793d2884c08ea924545a04e9544 (patch) | |
tree | ec6ecee89113ab9b173fba583018dbe9b0cd6495 | |
parent | fa40c4e16644da1f7c87cbd5a25d3fa8be4e0594 (diff) | |
download | uci-aa3ab8012bfbf793d2884c08ea924545a04e9544.tar.gz |
Fix memory leak in uci_list_config_files
When glob returns non-zero, the path buffer was not unallocated.
-rw-r--r-- | file.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -494,8 +494,10 @@ static char **uci_list_config_files(struct uci_context *ctx) dir = uci_malloc(ctx, strlen(ctx->confdir) + 1 + sizeof("/*")); sprintf(dir, "%s/*", ctx->confdir); - if (glob(dir, GLOB_MARK, NULL, &globbuf) != 0) + if (glob(dir, GLOB_MARK, NULL, &globbuf) != 0) { + free(dir); UCI_THROW(ctx, UCI_ERR_NOTFOUND); + } size = sizeof(char *) * (globbuf.gl_pathc + 1); for(i = 0; i < globbuf.gl_pathc; i++) { |