summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-09-19 08:53:25 +0200
committerGravatar Nikias Bassen2013-09-19 08:53:25 +0200
commitcab6533e63e390dccda15391cf3988e4d706a958 (patch)
tree07ff62ed66fa38a53c727cd455ab468fe0931d13 /common
parente53fcd1dd30f7dcd3c496ef25c3dea197e928ce7 (diff)
downloadlibimobiledevice-cab6533e63e390dccda15391cf3988e4d706a958.tar.gz
libimobiledevice-cab6533e63e390dccda15391cf3988e4d706a958.tar.bz2
userpref: fix leak and possible endless recursion in mkdir_with_parents
Diffstat (limited to 'common')
-rw-r--r--common/userpref.c11
1 files changed, 4 insertions, 7 deletions
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)
250 } 250 }
251 int res; 251 int res;
252 char *parent = strdup(dir); 252 char *parent = strdup(dir);
253 parent = dirname(parent); 253 char* parentdir = dirname(parent);
254 if (parent) { 254 if (parentdir) {
255 res = mkdir_with_parents(parent, mode); 255 res = mkdir_with_parents(parentdir, mode);
256 } else { 256 } else {
257 res = -1; 257 res = -1;
258 } 258 }
259 free(parent); 259 free(parent);
260 if (res == 0) {
261 mkdir_with_parents(dir, mode);
262 }
263 return res; 260 return res;
264} 261}
265 262