From b2b6465cf44d2bf3cbadabe97b157a527d3660d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 27 Nov 2014 17:23:48 -0500 Subject: [PATCH] Fix: Memory leak on error in alloc_argv_from_user_opts() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit *** CID 1256181: Resource leak (RESOURCE_LEAK) Signed-off-by: Jérémie Galarneau --- src/bin/lttng/commands/view.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/bin/lttng/commands/view.c b/src/bin/lttng/commands/view.c index 3c9975fa9..8763ac96e 100644 --- a/src/bin/lttng/commands/view.c +++ b/src/bin/lttng/commands/view.c @@ -172,6 +172,13 @@ static char **alloc_argv_from_user_opts(char *opts, const char *trace_path) return argv; error: + if (argv) { + for (i = 0; i < num_opts + 2; i++) { + free(argv[i]); + } + free(argv); + } + return NULL; } -- 2.34.1