From: Rosen Penev Date: Sun, 18 Dec 2016 01:12:28 +0000 (-0800) Subject: ubox: Fix some memory leaks X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=db070f15ac559e3bd406cb8b8cccf40f78e75094;p=oweals%2Fubox.git ubox: Fix some memory leaks Avoids leaking memory when exiting early. Signed-off by: Rosen --- diff --git a/kmodloader.c b/kmodloader.c index 40edbf0..f80835a 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -775,11 +775,15 @@ static int main_loader(int argc, char **argv) strcpy(path, dir); strcat(path, "*"); - if (scan_loaded_modules()) + if (scan_loaded_modules()) { + free (path); return -1; + } - if (scan_module_folders()) + if (scan_module_folders()) { + free (path); return -1; + } syslog(LOG_INFO, "kmodloader: loading kernel modules from %s\n", path); diff --git a/log/logd.c b/log/logd.c index d778909..915348e 100644 --- a/log/logd.c +++ b/log/logd.c @@ -84,7 +84,7 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj, struct blob_attr *msg) { struct client *cl; - struct blob_attr *tb[__READ_MAX]; + struct blob_attr *tb[__READ_MAX] = { 0 }; struct log_head *l; int count = 0; int fds[2]; diff --git a/validate/validate.c b/validate/validate.c index 5bc3bc4..0628407 100644 --- a/validate/validate.c +++ b/validate/validate.c @@ -173,8 +173,10 @@ dt_type_list(struct dt_state *s, int nargs) char *p, *str = strdup(s->value); const char *value = s->value; - if (!str || !nargs) + if (!str || !nargs) { + free(str); return false; + } for (p = strtok(str, " \t"); p; p = strtok(NULL, " \t")) {