From: Dhaval Giani Date: Tue, 16 Nov 2010 13:29:48 +0000 (+0100) Subject: v2 [patch 3/6] libcgroup: Fix up memory leak in cgroup_basename X-Git-Tag: v0.37~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4db4bc1293b48cd4719ec3a91ec2688fae790e83;p=thirdparty%2Flibcgroup.git v2 [patch 3/6] libcgroup: Fix up memory leak in cgroup_basename 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 Signed-off-by: Dhaval Giani Acked-By: Jan Safranek --- diff --git a/src/api.c b/src/api.c index a971ecd1..91483ca6 100644 --- 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;