From ba9a07165b36636e9dce03d5073cfecc8f092744 Mon Sep 17 00:00:00 2001 From: Mobin Aydinfar Date: Wed, 18 Dec 2024 23:50:25 +0330 Subject: [PATCH] FIX: dinit-iostream.h: Implement template write(...) in terms of that function write_nx(...) Signed-off-by: Mobin Aydinfar --- src/includes/dinit-iostream.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/includes/dinit-iostream.h b/src/includes/dinit-iostream.h index 1e9ea828..0bd8d19e 100644 --- a/src/includes/dinit-iostream.h +++ b/src/includes/dinit-iostream.h @@ -427,10 +427,12 @@ class ostream : public io_base template inline bool write(const A &a, const B &b, const C & ...c) { - if (!good()) return false; - if (!write(a)) return false; - if (!write(b, c...)) return false; - return true; + bool r = write_nx(a, b, c...); + if (!r) { + // This will definitely throw an exception + throw_exception_on(io_states::buffer_failbit | io_states::io_failbit); + } + return r; } // write_buf() functions, Used to write char* or std::string.