Skip to content

Commit

Permalink
Add check for unfinished format specifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC committed Nov 25, 2024
1 parent 9f46ec7 commit 661361e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/CCustomOpcodeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,19 @@ namespace CLEO

if (*iter == '%')
{
// end of format string
if (iter[1] == '\0')
{
LOG_WARNING(thread, "ReadFormattedString encountered incomplete format specifier in script %s", ((CCustomScript*)thread)->GetInfoStr().c_str());
SkipUnusedVarArgs(thread);
return -1; // error
}

// escaped % character
if (iter[1] == '%')
{
if (written++ >= len) goto _ReadFormattedString_OutOfMemory;
*outIter++ = '%'; /* "%%"->'%' */
*outIter++ = '%';
iter += 2;
continue;
}
Expand Down

0 comments on commit 661361e

Please sign in to comment.