]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: and cgroup.c: be overly cautious
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 22 May 2013 01:31:04 +0000 (20:31 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 22 May 2013 01:31:04 +0000 (20:31 -0500)
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 <serge.hallyn@ubuntu.com>
src/lxc/attach.c
src/lxc/cgroup.c

index d8b4915d55ebf708db323fc45efcb293157236c6..a33d24f89d18ccaae43d4f5c3e2734584fbdb9a2 100644 (file)
@@ -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) {
index 2ffbb54b5b95b68c14e27591c5db829765fb46bd..bb1268b30d19fe9ecfac88406d4a7880feab857f 100644 (file)
@@ -503,7 +503,8 @@ static char *get_all_cgroups(void)
        }
 
 out:
-       free(line);
+       if (line)
+               free(line);
        fclose(f);
        return ret;
 }