From b77d2a8c85339d296b91d6916742ab25300c5542 Mon Sep 17 00:00:00 2001 From: Junliang HU Date: Mon, 29 Mar 2021 21:01:07 +0800 Subject: [PATCH] Fix moving ostream while holding data --- include/fmt/os.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/fmt/os.h b/include/fmt/os.h index 0b0b94ed..78971e37 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -396,8 +396,10 @@ class ostream final : private detail::buffer { ostream(ostream&& other) : detail::buffer(other.data(), other.size(), other.capacity()), file_(std::move(other.file_)) { + other.clear(); other.set(nullptr, 0); } + ~ostream() { flush(); delete[] data();