diff options
author | Zack Middleton <zturtleman@gmail.com> | 2014-03-10 15:54:52 -0500 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-06-17 17:43:41 +0100 |
commit | 8fd8f7c57159f229d5186325b5777817e2d34305 (patch) | |
tree | 89493d479ca2f9269e54f185abd74b6c51264ec4 /src | |
parent | 08f82c18f8d36e38a80093d4463ae179af2b943d (diff) |
Fix error handling in R_ParseSpawnVars
When R_GetEntityToken returns qfalse it resets pointer for parsing, by
R_ParseSpawnVars not returning qfalse it could cause an infinite loop.
Also add newlines to printfs.
Diffstat (limited to 'src')
-rw-r--r-- | src/renderergl2/tr_bsp.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/renderergl2/tr_bsp.c b/src/renderergl2/tr_bsp.c index 3a38c9e5..75b2d1f5 100644 --- a/src/renderergl2/tr_bsp.c +++ b/src/renderergl2/tr_bsp.c @@ -2750,7 +2750,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp return qfalse; } if ( com_token[0] != '{' ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {",com_token ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {\n",com_token ); + return qfalse; } // go through all the key / value pairs @@ -2759,7 +2760,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp // parse key if ( !R_GetEntityToken( keyname, sizeof( keyname ) ) ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); + return qfalse; } if ( keyname[0] == '}' ) { @@ -2768,18 +2770,18 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp // parse value if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" ); - break; + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); + return qfalse; } if ( com_token[0] == '}' ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data" ); - break; + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data\n" ); + return qfalse; } if ( *numSpawnVars == MAX_SPAWN_VARS ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS" ); - break; + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS\n" ); + return qfalse; } keyLength = strlen(keyname) + 1; @@ -2787,8 +2789,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp if (numSpawnVarChars + keyLength + tokenLength > maxSpawnVarChars) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS" ); - break; + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS\n" ); + return qfalse; } strcpy(spawnVarChars + numSpawnVarChars, keyname); |