[PATCH] trace:fix memory leak in main

junnanx.xu at gmail.com junnanx.xu at gmail.com
Sat Jun 11 02:04:54 PDT 2022


From: Junnan XU <junnanx.xu at gmail.com>

Signed-off-by: Junnan XU <junnanx.xu at gmail.com>
---
 trace/trace.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/trace/trace.c b/trace/trace.c
index d895798..6fd321f 100644
--- a/trace/trace.c
+++ b/trace/trace.c
@@ -381,6 +381,10 @@ int main(int argc, char **argv, char **envp)
 		ULOG_ERR("failed to exec %s: %m\n", _argv[0]);
 
 		free(_argv);
+		if (_envp[0])
+			free(_envp[0]);
+		if (newenv == 2 && _envp[1])
+			free(_envp[1]);
 		free(_envp);
 		return ret;
 	}
-- 
2.36.1.windows.1




More information about the openwrt-devel mailing list