From: Serge Hallyn Date: Wed, 22 May 2013 01:31:04 +0000 (-0500) Subject: attach: and cgroup.c: be overly cautious X-Git-Tag: lxc-1.0.0.alpha1~1^2~193 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa9ac567a7f1593c586cca57362f6b542985e5d7;p=thirdparty%2Flxc.git attach: and cgroup.c: be overly cautious Realistically (as Dwight points out) it doesn't seem possible that getline won't return at least one line in this functions, however just to make absolutely sure we don't get a segv on free(NULL), check line != NULL before freeing it on exit. Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index d8b4915d5..a33d24f89 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -114,7 +114,8 @@ struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid) } } - free(line); + if (line) + free(line); fclose(proc_file); if (!found) { diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c index 2ffbb54b5..bb1268b30 100644 --- a/src/lxc/cgroup.c +++ b/src/lxc/cgroup.c @@ -503,7 +503,8 @@ static char *get_all_cgroups(void) } out: - free(line); + if (line) + free(line); fclose(f); return ret; }