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