aboutsummaryrefslogtreecommitdiffstats
path: root/code/botlib/l_script.c
diff options
context:
space:
mode:
authorthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2009-10-19 23:29:44 +0000
committerthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2009-10-19 23:29:44 +0000
commit12b36c8a3aa680f65df68c369a2803e83800d40f (patch)
tree0cf4e471203ed0653cb040857044aea2a08249d0 /code/botlib/l_script.c
parent05577376d95da42fe8cf3bb465ec4c628edb4ad7 (diff)
downloadioquake3-aero-12b36c8a3aa680f65df68c369a2803e83800d40f.tar.gz
ioquake3-aero-12b36c8a3aa680f65df68c369a2803e83800d40f.zip
Fix botlib parser for negative int/float values, thanks to Makro for reporting (#4227).
git-svn-id: svn://svn.icculus.org/quake3/trunk@1688 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/botlib/l_script.c')
-rw-r--r--code/botlib/l_script.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/code/botlib/l_script.c b/code/botlib/l_script.c
index c92481c..a579f28 100644
--- a/code/botlib/l_script.c
+++ b/code/botlib/l_script.c
@@ -1156,13 +1156,21 @@ float ReadSignedFloat(script_t *script)
PS_ExpectAnyToken(script, &token);
if (!strcmp(token.string, "-"))
{
+ if(!PS_ExpectAnyToken(script, &token))
+ {
+ ScriptError(script, "Missing float value\n", token.string);
+ return 0;
+ }
+
sign = -1.0;
- PS_ExpectTokenType(script, TT_NUMBER, 0, &token);
- } //end if
- else if (token.type != TT_NUMBER)
+ }
+
+ if (token.type != TT_NUMBER)
{
ScriptError(script, "expected float value, found %s\n", token.string);
- } //end else if
+ return 0;
+ }
+
return sign * token.floatvalue;
} //end of the function ReadSignedFloat
//============================================================================
@@ -1179,13 +1187,21 @@ signed long int ReadSignedInt(script_t *script)
PS_ExpectAnyToken(script, &token);
if (!strcmp(token.string, "-"))
{
+ if(!PS_ExpectAnyToken(script, &token))
+ {
+ ScriptError(script, "Missing integer value\n", token.string);
+ return 0;
+ }
+
sign = -1;
- PS_ExpectTokenType(script, TT_NUMBER, TT_INTEGER, &token);
- } //end if
- else if (token.type != TT_NUMBER || token.subtype == TT_FLOAT)
+ }
+
+ if (token.type != TT_NUMBER || token.subtype == TT_FLOAT)
{
ScriptError(script, "expected integer value, found %s\n", token.string);
- } //end else if
+ return 0;
+ }
+
return sign * token.intvalue;
} //end of the function ReadSignedInt
//============================================================================