[OpenWrt-Devel] [PATCH netifd 11/16] handler: Fix memory leak

Hans Dedecker dedeckeh at gmail.com
Mon Feb 1 04:56:25 EST 2016


Call globfree to free dynamically allocated storage from a previous glob call

Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
 handler.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/handler.c b/handler.c
index f81a7c5..0c4627f 100644
--- a/handler.c
+++ b/handler.c
@@ -128,10 +128,14 @@ void netifd_init_script_handlers(int dir_fd, script_dump_cb cb)
 	int i, prev_fd;
 
 	prev_fd = netifd_dir_push(dir_fd);
-	glob("./*.sh", 0, NULL, &g);
+	if (glob("./*.sh", 0, NULL, &g))
+		return;
+
 	for (i = 0; i < g.gl_pathc; i++)
 		netifd_parse_script_handler(g.gl_pathv[i], cb);
 	netifd_dir_pop(prev_fd);
+
+	globfree(&g);
 }
 
 char *
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list