From 83fa108f99ac32430d211f9e5f8676463c4e6cee Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 18 Dec 2025 13:27:37 +0100 Subject: [PATCH] stream: fix cache flush when stream is at EOF Signed-off-by: Simon Rozman --- include/stdex/stream.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index 490b8c308..cbc786262 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -1816,8 +1816,7 @@ namespace stdex void init(_Inout_ basic_file& source) { m_source = &source; - m_state = m_source->state(); - if (m_source->ok()) { + if ((m_state = m_source->state()) != state_t::fail) { m_offset = m_source->tell(); #if SET_FILE_OP_TIMES m_atime = m_source->atime(); @@ -1828,7 +1827,7 @@ namespace stdex void done() { - if (m_source && m_source->ok()) { + if (m_source && m_source->state() != state_t::fail) { flush_cache(); if (!ok()) _Unlikely_ throw std::system_error(sys_error(), std::system_category(), "failed to flush cache"); // Data loss occurred