diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2020-02-23 22:12:27 +0000 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2020-02-23 22:12:27 +0000 |
commit | 450f803dd75f831f8ee14072fe0eb664bbe518df (patch) | |
tree | b3e831d44df50348a20f3541b6062f7fbab6ff3d /zen/zlib_wrap.h | |
parent | Merge branch '10.19' into 'master' (diff) | |
parent | remove upstream deleted files (diff) | |
download | FreeFileSync-450f803dd75f831f8ee14072fe0eb664bbe518df.tar.gz FreeFileSync-450f803dd75f831f8ee14072fe0eb664bbe518df.tar.bz2 FreeFileSync-450f803dd75f831f8ee14072fe0eb664bbe518df.zip |
Merge branch '10.20' into 'master'10.20
add upstream 10.20
See merge request opensource-tracking/FreeFileSync!17
Diffstat (limited to 'zen/zlib_wrap.h')
-rw-r--r-- | zen/zlib_wrap.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/zen/zlib_wrap.h b/zen/zlib_wrap.h index 9d9229ac..b820a4f8 100644 --- a/zen/zlib_wrap.h +++ b/zen/zlib_wrap.h @@ -27,8 +27,8 @@ BinContainer decompress(const BinContainer& stream); //throw SysError class InputStreamAsGzip //convert input stream into gzip on the fly { public: - InputStreamAsGzip( //throw SysError - const std::function<size_t(void* buffer, size_t bytesToRead)>& readBlock /*throw X*/); //returning 0 signals EOF: Posix read() semantics + explicit InputStreamAsGzip( //throw SysError + const std::function<size_t(void* buffer, size_t bytesToRead)>& readBlock /*throw X; returning 0 signals EOF: Posix read() semantics*/); ~InputStreamAsGzip(); size_t read(void* buffer, size_t bytesToRead); //throw SysError, X; return "bytesToRead" bytes unless end of stream! @@ -38,6 +38,7 @@ private: const std::unique_ptr<Impl> pimpl_; }; +std::string compressAsGzip(const void* buffer, size_t bufSize); //throw SysError @@ -103,10 +104,9 @@ BinContainer decompress(const BinContainer& stream) //throw SysError { contOut.resize(static_cast<size_t>(uncompressedSize)); //throw std::bad_alloc } - catch (const std::bad_alloc& e) //most likely due to data corruption! - { - throw SysError(L"zlib error: " + _("Out of memory.") + L" " + utfTo<std::wstring>(e.what())); - } + //most likely this is due to data corruption: + catch (const std::length_error& e) { throw SysError(L"zlib error: " + _("Out of memory.") + L" " + utfTo<std::wstring>(e.what())); } + catch (const std::bad_alloc& e) { throw SysError(L"zlib error: " + _("Out of memory.") + L" " + utfTo<std::wstring>(e.what())); } const size_t bytesWritten = impl::zlib_decompress(&*stream.begin() + sizeof(uncompressedSize), stream.size() - sizeof(uncompressedSize), |