diff options
author | saturneric <[email protected]> | 2024-01-18 05:32:25 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-18 05:32:25 +0000 |
commit | 38e4a656dbdd14cf7a6a91cda6c814b5290acd93 (patch) | |
tree | 33f614f861dec8fef4ea456dda26abab2e3329f5 /src/core/function/ArchiveFileOperator.cpp | |
parent | fix: improve code quality, docs and ci files (diff) | |
download | GpgFrontend-38e4a656dbdd14cf7a6a91cda6c814b5290acd93.tar.gz GpgFrontend-38e4a656dbdd14cf7a6a91cda6c814b5290acd93.zip |
fix: slove codacy issues
Diffstat (limited to 'src/core/function/ArchiveFileOperator.cpp')
-rw-r--r-- | src/core/function/ArchiveFileOperator.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/function/ArchiveFileOperator.cpp b/src/core/function/ArchiveFileOperator.cpp index 54c78628..aad8b525 100644 --- a/src/core/function/ArchiveFileOperator.cpp +++ b/src/core/function/ArchiveFileOperator.cpp @@ -159,10 +159,22 @@ void ArchiveFileOperator::NewArchive2DataExchanger( auto fd = open(archive_entry_sourcepath(entry), O_RDONLY); auto len = read(fd, buff.data(), buff.size()); assert(len <= buff.size() && len > 0); + if (len == -1) { + GF_CORE_LOG_ERROR("read() failed, ret: {}, abort ...", r); + archive_entry_free(entry); + close(fd); + break; + } while (len > 0) { archive_write_data(archive, buff.data(), len); len = read(fd, buff.data(), buff.size()); assert(len <= buff.size() && len > 0); + if (len == -1) { + GF_CORE_LOG_ERROR("read() failed, ret: {}, abort ...", r); + archive_entry_free(entry); + close(fd); + break; + } } close(fd); } |