diff options
| author | YongDo-Hyun <froster12@naver.com> | 2025-12-27 16:24:03 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-03-27 19:57:09 +0300 |
| commit | 65f57b875f164ed693cdacd1125a64de7f98a515 (patch) | |
| tree | d8aa0d912367e7909a5533bc9710405c3a2078de /src/io/ozlibstream.cpp | |
| parent | 7c71181c27c3ccedf8f183b041dd7656e764cdb3 (diff) | |
| download | Project-Tick-65f57b875f164ed693cdacd1125a64de7f98a515.tar.gz Project-Tick-65f57b875f164ed693cdacd1125a64de7f98a515.zip | |
fix: correct exception handling in ozlibstream::close method
Signed-off-by: YongDo-Hyun <froster12@naver.com>
Diffstat (limited to 'src/io/ozlibstream.cpp')
| -rw-r--r-- | src/io/ozlibstream.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/io/ozlibstream.cpp b/src/io/ozlibstream.cpp index ba6187645c..d1cb25dac0 100644 --- a/src/io/ozlibstream.cpp +++ b/src/io/ozlibstream.cpp @@ -113,15 +113,14 @@ void ozlibstream::close() // `setstate` to throw an `ios_base::failure` which would replace // the original exception. Temporarily disable exceptions on this // stream, set the `badbit`, then restore the exception mask. + std::ios_base::iostate old_ex = exceptions(); + exceptions(std::ios_base::goodbit); + setstate(std::ios_base::badbit); try { - exceptions(std::ios_base::goodbit); - setstate(std::ios_base::badbit); - } - catch(...) { - // If anything unexpected happens while setting state, swallow - // it — we don't want this to throw here. + exceptions(old_ex); + } catch (...) { + // If anything unexpected happens while restoring the exception mask, + // swallow it — we don't want this to throw here. } - exceptions(old_ex); -} - + } } |
