From e8a387fa16fc7b72d7f4cf0188ba375d1abf56ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chaloupka?= Date: Mon, 19 Oct 2020 08:21:56 +0200 Subject: [PATCH] Fix #2484 - clear `m_fill` on flush exception --- stream/vibe/stream/wrapper.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stream/vibe/stream/wrapper.d b/stream/vibe/stream/wrapper.d index 9188da0e8e..6302803873 100644 --- a/stream/vibe/stream/wrapper.d +++ b/stream/vibe/stream/wrapper.d @@ -309,14 +309,15 @@ struct StreamOutputRange(OutputStream, size_t buffer_size = 256) ~this() { + scope (failure) () @trusted { destroy(m_stream); }(); // workaround for #2484 flush(); } void flush() { if (m_fill == 0) return; + scope (exit) m_fill = 0; m_stream.write(m_data[0 .. m_fill]); - m_fill = 0; } void drop()