aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandeep Dhavale <dhavale@google.com>2023-09-19 14:02:20 -0700
committerGao Xiang <hsiangkao@linux.alibaba.com>2023-09-20 19:35:12 +0800
commitc60712e595273bb3035d1789a3b8c2a8f8130cb1 (patch)
tree75a943f0842779a1403286be0b227d732a3f7a37
parente3dfe4b8db26522004b6ba526cd0eae8622ced1a (diff)
downloaderofs-utils-c60712e595273bb3035d1789a3b8c2a8f8130cb1.tar.gz
erofs-utils: lib: Restore memory address before free()
We move `idx` pointer as we iterate through for loop based on `count`. If we error out from the loop, use the original pointer of allocated memory when calling free(). Fixes: 39147b48b76d ("erofs-utils: lib: add erofs_rebuild_load_tree() helper") Signed-off-by: Sandeep Dhavale <dhavale@google.com> Link: https://lore.kernel.org/r/20230919210220.3657736-1-dhavale@google.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
-rw-r--r--lib/rebuild.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/rebuild.c b/lib/rebuild.c
index 9751f0e..5993730 100644
--- a/lib/rebuild.c
+++ b/lib/rebuild.c
@@ -192,7 +192,7 @@ static int erofs_rebuild_fixup_inode_index(struct erofs_inode *inode)
inode->u.chunkformat |= chunkbits - sbi.blkszbits;
return 0;
err:
- free(idx);
+ free(inode->chunkindexes);
inode->chunkindexes = NULL;
return ret;
}