static void open_cgroup_procs(void)
{
- char *buf = NULL, *path = NULL;
- int cgroup_fd;
+ char *buf = NULL, *path = NULL, *p;
+ int cgroup_fd = 0;
char fdpath[PATH_MAX];
open_target_fd(&cgroup_fd, "cgroup", optarg);
if (read_all_alloc(cgroup_fd, &buf) < 1)
err(EXIT_FAILURE, _("failed to get cgroup path"));
- path = strrchr(strtok(buf, "\n"), ':');
+ p = strtok(buf, "\n");
+ if (p)
+ path = strrchr(p, ':');
if (!path)
err(EXIT_FAILURE, _("failed to get cgroup path"));
path++;