summaryrefslogtreecommitdiffstats
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
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()
-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)
if (srcpath && dstpath) {
/* copy file */
mb2_copy_file_by_path(srcpath, dstpath);
+ }
+ if (srcpath)
free(srcpath);
+ if (dstpath)
free(dstpath);
- }
}
closedir(cur_dir);
}