Skip to content

Commit 35d3980

Browse files
author
Hongzhen Luo
committed
[EROFS]: fix: capture errors from extract_tar()
Currently, the error code returned by the earlier part of the extract_tar() may be overwritten by value of erofs_close_sbi(). This patch introduces `err2` to address this issue. Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
1 parent db0879a commit 35d3980

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/overlaybd/tar/erofs/liberofs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ int LibErofs::extract_tar(photon::fs::IFile *source, bool meta_only, bool first_
624624
struct erofs_mkfs_cfg mkfs_cfg;
625625
struct erofs_configure *erofs_cfg;
626626
struct liberofs_file target_file, source_file;
627-
int err;
627+
int err, err2;
628628

629629
target_file.ops.pread = erofs_target_pread;
630630
target_file.ops.pwrite = erofs_target_pwrite;
@@ -690,11 +690,11 @@ int LibErofs::extract_tar(photon::fs::IFile *source, bool meta_only, bool first_
690690
goto exit;
691691
}
692692
exit:
693-
err = erofs_close_sbi(&sbi, target_file.cache);
693+
err2 = erofs_close_sbi(&sbi, target_file.cache);
694694
erofs_close_tar(&erofstar);
695695
std::fclose(mkfs_cfg.mp_fp);
696696
delete target_file.cache;
697-
return err;
697+
return err ? err : err2;
698698
}
699699

700700
LibErofs::LibErofs(photon::fs::IFile *target, uint64_t blksize, bool import_tar_headers)

0 commit comments

Comments
 (0)