mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-01-25 02:41:22 +00:00
[q3map2] Unwind script stack in case of script loading error.
Also avoid type punning read into char* variable (even though char* and void* happen to be layout-compatible).
This commit is contained in:
parent
606d72adf2
commit
760623150e
1 changed files with 8 additions and 5 deletions
|
@ -58,6 +58,7 @@ qboolean tokenready; // only qtrue if UnGetToken was just ca
|
||||||
*/
|
*/
|
||||||
void AddScriptToStack( const char *filename, int index ){
|
void AddScriptToStack( const char *filename, int index ){
|
||||||
int size;
|
int size;
|
||||||
|
void* buffer;
|
||||||
|
|
||||||
script++;
|
script++;
|
||||||
if ( script == &scriptstack[MAX_INCLUDES] ) {
|
if ( script == &scriptstack[MAX_INCLUDES] ) {
|
||||||
|
@ -65,10 +66,11 @@ void AddScriptToStack( const char *filename, int index ){
|
||||||
}
|
}
|
||||||
strcpy( script->filename, ExpandPath( filename ) );
|
strcpy( script->filename, ExpandPath( filename ) );
|
||||||
|
|
||||||
size = vfsLoadFile( script->filename, (void **)&script->buffer, index );
|
size = vfsLoadFile( script->filename, &buffer, index );
|
||||||
|
|
||||||
if ( size == -1 ) {
|
if ( size == -1 ) {
|
||||||
Sys_Printf( "Script file %s was not found\n", script->filename );
|
Sys_Printf( "Script file %s was not found\n", script->filename );
|
||||||
|
script--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -78,11 +80,12 @@ void AddScriptToStack( const char *filename, int index ){
|
||||||
else{
|
else{
|
||||||
Sys_Printf( "entering %s\n", script->filename );
|
Sys_Printf( "entering %s\n", script->filename );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
script->line = 1;
|
script->buffer = buffer;
|
||||||
script->script_p = script->buffer;
|
script->line = 1;
|
||||||
script->end_p = script->buffer + size;
|
script->script_p = script->buffer;
|
||||||
|
script->end_p = script->buffer + size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue