diff options
| author | 2013-09-19 08:53:25 +0200 | |
|---|---|---|
| committer | 2013-09-19 08:53:25 +0200 | |
| commit | cab6533e63e390dccda15391cf3988e4d706a958 (patch) | |
| tree | 07ff62ed66fa38a53c727cd455ab468fe0931d13 | |
| parent | e53fcd1dd30f7dcd3c496ef25c3dea197e928ce7 (diff) | |
| download | libimobiledevice-cab6533e63e390dccda15391cf3988e4d706a958.tar.gz libimobiledevice-cab6533e63e390dccda15391cf3988e4d706a958.tar.bz2 | |
userpref: fix leak and possible endless recursion in mkdir_with_parents
| -rw-r--r-- | common/userpref.c | 11 |
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 | ||
