Skip to content

Commit

Permalink
Fix bug in assert() based error handling
Browse files Browse the repository at this point in the history
Force return after call to TINYFORMAT_ERROR to avoid bad indexing if the
user has supplied too few arguments.
  • Loading branch information
c42f committed Jun 15, 2014
1 parent 4600311 commit 733274a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tinyformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,10 @@ inline void formatImpl(std::ostream& out, const char* fmt,
if(wantWidth || wantPrecision)
{
if (argIndex + (int) wantWidth + (int) wantPrecision >= numFormatters)
{
TINYFORMAT_ERROR("Not enough arguments for variable width or precision");
return;
}
int variableWidth = 0;
int variablePrecision = 0;
if (wantWidth)
Expand Down

0 comments on commit 733274a

Please sign in to comment.