summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Bastien Nocera2018-07-24 14:21:10 +0200
committerGravatar Bastien Nocera2018-07-24 14:36:27 +0200
commit370a323148f691a5bb8f1d59b3c4aaf439f2d4b2 (patch)
treeb86f3637c59bfbd1e818941bcca82c5bc8521946 /tools
parentc7ead85cb9daabe26df467b16ddefbbc7b1d3f3c (diff)
downloadlibimobiledevice-370a323148f691a5bb8f1d59b3c4aaf439f2d4b2.tar.gz
libimobiledevice-370a323148f691a5bb8f1d59b3c4aaf439f2d4b2.tar.bz2
idevicebackup2: Fix potential memleak
If either of dstpath or srcpath can be NULL, then make sure they get freed irrespective of the other variable's value in mb2_copy_directory_by_path()
Diffstat (limited to 'tools')
-rw-r--r--tools/idevicebackup2.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index 010e51d..84b8a61 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -1204,10 +1204,12 @@ static void mb2_copy_directory_by_path(const char *src, const char *dst)
1204 if (srcpath && dstpath) { 1204 if (srcpath && dstpath) {
1205 /* copy file */ 1205 /* copy file */
1206 mb2_copy_file_by_path(srcpath, dstpath); 1206 mb2_copy_file_by_path(srcpath, dstpath);
1207 }
1207 1208
1209 if (srcpath)
1208 free(srcpath); 1210 free(srcpath);
1211 if (dstpath)
1209 free(dstpath); 1212 free(dstpath);
1210 }
1211 } 1213 }
1212 closedir(cur_dir); 1214 closedir(cur_dir);
1213 } 1215 }