mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-04 11:03:30 +01:00
Avoid zero width in Tbc::Text
- causes underflow (and ultimately out_of_range exception) when there are no wrappable characters and substring of width-1 is extracted
This commit is contained in:
parent
1501339438
commit
33d8d9c5ee
6
include/external/tbc_text_format.h
vendored
6
include/external/tbc_text_format.h
vendored
@ -77,9 +77,9 @@ namespace Tbc {
|
||||
pos = remainder.find_last_of( _attr.tabChar, width );
|
||||
if( pos != std::string::npos ) {
|
||||
tabPos = pos;
|
||||
if( remainder[width] == '\n' )
|
||||
if( width == remainder.size() || remainder[width] == '\n' )
|
||||
width--;
|
||||
remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
|
||||
remainder.erase( tabPos, 1 );
|
||||
}
|
||||
|
||||
if( width == remainder.size() ) {
|
||||
@ -104,7 +104,7 @@ namespace Tbc {
|
||||
}
|
||||
if( lines.size() == 1 )
|
||||
indent = _attr.indent;
|
||||
if( tabPos != std::string::npos )
|
||||
if( tabPos < _attr.width - indent )
|
||||
indent += tabPos;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user