CON: proper bound checks for {re,}definequote commands.

git-svn-id: https://svn.eduke32.com/eduke32@3262 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-12-09 13:42:38 +00:00
parent f2a9af0bae
commit 10ae7e342c

View file

@ -5313,7 +5313,8 @@ repeatcase:
initprintf("%s:%d: error: quote number exceeds limit of %d.\n",g_szScriptFileName,g_lineNumber,MAXQUOTES);
g_numCompilerErrors++;
}
else
{
if (ScriptQuotes[k] == NULL)
ScriptQuotes[k] = (char *)Bcalloc(MAXQUOTELEN,sizeof(uint8_t));
@ -5323,6 +5324,7 @@ repeatcase:
Bsprintf(tempbuf,"Failed allocating %" PRIdPTR " byte quote text buffer.",sizeof(uint8_t) * MAXQUOTELEN);
G_GameExit(tempbuf);
}
}
if (tw == CON_DEFINEQUOTE)
g_scriptPtr--;
@ -5336,9 +5338,8 @@ repeatcase:
{
if (ScriptQuoteRedefinitions[g_numQuoteRedefinitions] == NULL)
ScriptQuoteRedefinitions[g_numQuoteRedefinitions] = (char *)Bcalloc(MAXQUOTELEN,sizeof(uint8_t));
if (!ScriptQuoteRedefinitions[g_numQuoteRedefinitions])
if (ScriptQuoteRedefinitions[g_numQuoteRedefinitions] == NULL)
{
ScriptQuoteRedefinitions[g_numQuoteRedefinitions] = NULL;
Bsprintf(tempbuf,"Failed allocating %" PRIdPTR " byte quote text buffer.",sizeof(uint8_t) * MAXQUOTELEN);
G_GameExit(tempbuf);
}
@ -5368,8 +5369,12 @@ repeatcase:
break;
}
}
if (tw == CON_DEFINEQUOTE)
{
if ((unsigned)k < MAXQUOTES)
*(ScriptQuotes[k]+i) = '\0';
}
else
{
*(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = '\0';