Fix potential buffer overflow in PS_ReadPrimitive

Found by Coverity.
This commit is contained in:
Zack Middleton 2014-05-25 16:28:38 -05:00
parent e21ff01946
commit 078d004dc2

View file

@ -828,7 +828,7 @@ int PS_ReadPrimitive(script_t *script, token_t *token)
len = 0; len = 0;
while(*script->script_p > ' ' && *script->script_p != ';') while(*script->script_p > ' ' && *script->script_p != ';')
{ {
if (len >= MAX_TOKEN) if (len >= MAX_TOKEN - 1)
{ {
ScriptError(script, "primitive token longer than MAX_TOKEN = %d", MAX_TOKEN); ScriptError(script, "primitive token longer than MAX_TOKEN = %d", MAX_TOKEN);
return 0; return 0;