From cde0c548d63abc758e9ba6520efe0d17e1267206 Mon Sep 17 00:00:00 2001 From: Ivana Hutarova Varekova Date: Wed, 9 Oct 2013 11:41:22 +0200 Subject: [PATCH] cgroup_get_current_controller_path: test whether strtok_r returns NULL cgroup_get_current_controller_path should test whether strtok_r returns NULL before it continues. Signed-off-by: Ivana Hutarova Varekova Acked-by: Peter Schiffer Acked-by: Dhaval Giani --- src/api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api.c b/src/api.c index d5d0ce75..ba977683 100644 --- a/src/api.c +++ b/src/api.c @@ -3303,7 +3303,7 @@ int cgroup_get_current_controller_path(pid_t pid, const char *controller, } token = strtok_r(controllers, ",", &savedptr); - do { + while (token) { if (strncmp(controller, token, strlen(controller) + 1) == 0) { *current_path = strdup(cgroup_path); @@ -3316,7 +3316,7 @@ int cgroup_get_current_controller_path(pid_t pid, const char *controller, goto done; } token = strtok_r(NULL, ",", &savedptr); - } while (token); + } } done: -- 2.47.2