From cab6533e63e390dccda15391cf3988e4d706a958 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 19 Sep 2013 08:53:25 +0200 Subject: userpref: fix leak and possible endless recursion in mkdir_with_parents --- common/userpref.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/userpref.c b/common/userpref.c index 231d456..ec1b182 100644 --- a/common/userpref.c +++ b/common/userpref.c @@ -250,16 +250,13 @@ static int mkdir_with_parents(const char *dir, int mode) } int res; char *parent = strdup(dir); - parent = dirname(parent); - if (parent) { - res = mkdir_with_parents(parent, mode); + char* parentdir = dirname(parent); + if (parentdir) { + res = mkdir_with_parents(parentdir, mode); } else { - res = -1; + res = -1; } free(parent); - if (res == 0) { - mkdir_with_parents(dir, mode); - } return res; } -- cgit v1.1-32-gdbae