[lxc-devel] [PATCH] fix free() of args to startl

Dwight Engen dwight.engen at oracle.com
Tue Oct 29 18:38:00 UTC 2013


Coverity 1076328 marked this as "Use after free", which it isn't really,
its actually just free()ing the wrong 2nd, 3rd, etc... pointers. Test by
passing two or more args to startl, without this change you get segfault
when free()ing the second pointer/arg.

Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
 src/lxc/lxccontainer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index f2f7240..9d537a6 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -641,9 +641,9 @@ static bool lxcapi_startl(struct lxc_container *c, int useinit, ...)
 
 out:
 	if (inargs) {
-		char *arg;
-		for (arg = *inargs; arg; arg++)
-			free(arg);
+		char **arg;
+		for (arg = inargs; *arg; arg++)
+			free(*arg);
 		free(inargs);
 	}
 
-- 
1.8.3.1





More information about the lxc-devel mailing list