From c165bd15c5017137db38e149c8c8b68f1233fa96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 4 Nov 2019 00:05:32 +0100 Subject: [PATCH] Forbid copying ReusableStringStream Copying a `ReusableStringStream` would lead to "double free" of the stream, and thus it could be used in multiple places at the same time, breaking the output. --- src/catch2/catch_stream.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/catch2/catch_stream.h b/src/catch2/catch_stream.h index 2b41adbd..999849c9 100644 --- a/src/catch2/catch_stream.h +++ b/src/catch2/catch_stream.h @@ -9,6 +9,8 @@ #ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED #define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED +#include "catch_common.h" + #include #include #include @@ -28,7 +30,7 @@ namespace Catch { auto makeStream( StringRef const &filename ) -> IStream const*; - class ReusableStringStream { + class ReusableStringStream : NonCopyable { std::size_t m_index; std::ostream* m_oss; public: