Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Restated text format loop to avoid out-of-bounds condition

Commit
f347611403b35959c9ab57f52a86f130c225d50f
Author
Phil Nash ·
Parents
1efd8d306700

Files · Download .tar.gz

Changes

 include/external/tbc_text_format.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/external/tbc_text_format.h b/include/external/tbc_text_format.h
index a239b088..5209d804 100644
--- a/include/external/tbc_text_format.h
+++ b/include/external/tbc_text_format.h
@@ -84,8 +84,8 @@ namespace Tbc {
 
                 if( itEnd != strEnd  ) {
                     bool foundWrapPoint = false;
-                    for( iterator findIt = itEnd; !foundWrapPoint & findIt >= it; --findIt ) {
-
+                    iterator findIt = itEnd;
+                    do {
                         if( wrappableAfterChars.find( *findIt ) != std::string::npos && findIt != itEnd ) {
                             itEnd = findIt+1;
                             itNext = findIt+1;
@@ -101,7 +101,13 @@ namespace Tbc {
                             itEnd = findIt;
                             foundWrapPoint = true;
                         }
+                        if( findIt == it )
+                            break;
+                        else
+                            --findIt;
                     }
+                    while( !foundWrapPoint );
+
                     if( !foundWrapPoint ) {
                         // No good wrap char, so we'll break mid word and add a hyphen
                         --itEnd;