From: Ivana Hutarova Varekova Date: Wed, 9 Oct 2013 09:39:47 +0000 (+0200) Subject: cgroup_copy_with_slash: two typos X-Git-Tag: v0.41~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=424b5d509fdddbdeda626bb2395032ece2e3e723;p=thirdparty%2Flibcgroup.git 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 --- 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;