diff --git a/include/tclap/StdOutput.h b/include/tclap/StdOutput.h index 9dd6d0f..9ceac0c 100644 --- a/include/tclap/StdOutput.h +++ b/include/tclap/StdOutput.h @@ -248,10 +248,10 @@ inline void StdOutput::spacePrint( std::ostream& os, // trim the length so it doesn't end in middle of a word if ( stringLen == allowedLen ) - while ( s[stringLen+start] != ' ' && + while ( stringLen >= 0 && + s[stringLen+start] != ' ' && s[stringLen+start] != ',' && - s[stringLen+start] != '|' && - stringLen >= 0 ) + s[stringLen+start] != '|' ) stringLen--; // ok, the word is longer than the line, so just split