From 3a6a9d01deb0692cae890a08e75a7218fd3bb07f Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 15 Oct 2023 20:03:32 -0400 Subject: [PATCH] Fix infinite recursion due to not resetting the main streambuf. --- word_wrap.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/word_wrap.cpp b/word_wrap.cpp index b16d74e..79dc8d4 100644 --- a/word_wrap.cpp +++ b/word_wrap.cpp @@ -135,6 +135,7 @@ namespace Alepha::Cavorite ::detail:: word_wrap { auto *const streambuf= static_cast< WordWrapStreambuf * >( ios.pword( wrapperIndex ) ); streambuf->drain(); + dynamic_cast< std::ostream & >( ios ).rdbuf( streambuf->underlying ); delete streambuf; ios.pword( wrapperIndex )= nullptr; } @@ -177,6 +178,7 @@ namespace Alepha::Cavorite ::detail:: word_wrap state= 1; os.register_callback( wordwrapCallback, wrapperIndex ); } + assert( os.pword( wrapperIndex ) == nullptr ); os.pword( wrapperIndex )= buf.release(); return os;