]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
v2 [patch 3/6] libcgroup: Fix up memory leak in cgroup_basename
authorDhaval Giani <dhaval.giani@gmail.com>
Tue, 16 Nov 2010 13:29:48 +0000 (14:29 +0100)
committerDhaval Giani <dhaval.giani@gmail.com>
Tue, 16 Nov 2010 15:39:17 +0000 (16:39 +0100)
We were not freeing up tmp_string if the strdup for basename failed.

Since we anyway need to free up tmp_string and return NULL if the
strdup failed, we don't really care about testing the return value
of the strdup, and therefore this check is not needed. Remove this
check then.

Thanks to Steve Grubb's review at
http://article.gmane.org/gmane.comp.lib.libcg.devel/2485

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
src/api.c

index a971ecd10f3a8f8c7e1caae53c7b5ca8c27e83ad..91483ca6b41821df6acf4e3276a81fb07527fe86 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -276,9 +276,6 @@ static char *cgroup_basename(const char *path)
 
        base = strdup(basename(tmp_string));
 
-       if (!base)
-               return NULL;
-
        free(tmp_string);
 
        return base;