From 424b5d509fdddbdeda626bb2395032ece2e3e723 Mon Sep 17 00:00:00 2001 From: Ivana Hutarova Varekova Date: Wed, 9 Oct 2013 11:39:47 +0200 Subject: [PATCH] cgroup_copy_with_slash: two typos Fix a typo when the '/' character is tested on the last but one position instead of the last. There have to be more allocated more memory in the same function. 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 f78704af..d5d0ce75 100644 --- a/src/api.c +++ b/src/api.c @@ -2707,10 +2707,10 @@ char *cgroup_copy_with_slash(char *input) int len = strlen(input); /* if input does not end with '/', allocate one more space for it */ - if ((input[len-2]) != '/') + if ((input[len-1]) != '/') len = len+1; - output = (char *)malloc(sizeof(char)*(len)); + output = (char *)malloc(sizeof(char)*(len+1)); if (output == NULL) return NULL; -- 2.47.2