libcgroup: Fix memory leak in cg_mkdir_p

While reading the code, I realized that we were never allocating memory
to buf in cg_mkdir_p. On reading the manpages, I realized that getcwd
allocates memory, but it has to be freed by the caller. Fix this
memory leak.

Signed-off-by: Dhaval Giani <[email protected]>
---
 api.c |    2 ++
 1 file changed, 2 insertions(+)

Index: trunk/api.c
===================================================================
--- trunk.orig/api.c    2009-01-04 20:43:29.000000000 +0530
+++ trunk/api.c 2009-01-04 20:46:22.000000000 +0530
@@ -905,6 +905,8 @@ static int cg_mkdir_p(const char *path)
                printf("could not go back to old directory (%s)\n", cwd);
 
 done:
+       if (buf)
+               free(buf);
        free(real_path);
        return ret;
 }
-- 
regards,
Dhaval

------------------------------------------------------------------------------
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to