]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
cgroup_copy_with_slash: two typos
authorIvana Hutarova Varekova <varekova@redhat.com>
Wed, 9 Oct 2013 09:39:47 +0000 (11:39 +0200)
committerIvana Hutarova Varekova <varekova@redhat.com>
Wed, 9 Oct 2013 09:39:47 +0000 (11:39 +0200)
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 <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
src/api.c

index f78704afcb70f20796009c8c2c433ddec744b84c..d5d0ce75d503f2918a2eaa7014ed45cfd280c18c 100644 (file)
--- 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;