1
0
forked from Alepha/Alepha

Fix infinite recursion due to not resetting the main streambuf.

This commit is contained in:
2023-10-15 20:03:32 -04:00
parent 8fce9c675f
commit 3a6a9d01de

View File

@ -135,6 +135,7 @@ namespace Alepha::Cavorite ::detail:: word_wrap
{ {
auto *const streambuf= static_cast< WordWrapStreambuf * >( ios.pword( wrapperIndex ) ); auto *const streambuf= static_cast< WordWrapStreambuf * >( ios.pword( wrapperIndex ) );
streambuf->drain(); streambuf->drain();
dynamic_cast< std::ostream & >( ios ).rdbuf( streambuf->underlying );
delete streambuf; delete streambuf;
ios.pword( wrapperIndex )= nullptr; ios.pword( wrapperIndex )= nullptr;
} }
@ -177,6 +178,7 @@ namespace Alepha::Cavorite ::detail:: word_wrap
state= 1; state= 1;
os.register_callback( wordwrapCallback, wrapperIndex ); os.register_callback( wordwrapCallback, wrapperIndex );
} }
assert( os.pword( wrapperIndex ) == nullptr );
os.pword( wrapperIndex )= buf.release(); os.pword( wrapperIndex )= buf.release();
return os; return os;