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 <serge.hallyn@ubuntu.com>
This commit is contained in:
Serge Hallyn 2013-05-21 20:31:04 -05:00
parent 20fe4e8feb
commit fa9ac567a7
2 changed files with 4 additions and 2 deletions

View 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) {

View File

@ -503,7 +503,8 @@ static char *get_all_cgroups(void)
}
out:
free(line);
if (line)
free(line);
fclose(f);
return ret;
}