From 370a323148f691a5bb8f1d59b3c4aaf439f2d4b2 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 24 Jul 2018 14:21:10 +0200 Subject: 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() --- tools/idevicebackup2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- cgit v1.1-32-gdbae