From 4db4bc1293b48cd4719ec3a91ec2688fae790e83 Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Tue, 16 Nov 2010 14:29:48 +0100 Subject: [PATCH] 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 --- src/api.c | 3 --- 1 file changed, 3 deletions(-) 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; -- 2.47.2