Commit fa9ac567 by Serge Hallyn

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: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 20fe4e8f
...@@ -114,7 +114,8 @@ struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid) ...@@ -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); fclose(proc_file);
if (!found) { if (!found) {
......
...@@ -503,7 +503,8 @@ static char *get_all_cgroups(void) ...@@ -503,7 +503,8 @@ static char *get_all_cgroups(void)
} }
out: out:
free(line); if (line)
free(line);
fclose(f); fclose(f);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment