From c436f453ac018b608ceb89ceae2b289300fce3f0 Mon Sep 17 00:00:00 2001 From: Martin Janitschke Date: Sun, 23 Feb 2014 19:53:55 -0500 Subject: [PATCH] Fix 3D viewer crash bug. (fixes lp:673603 and lp:804778) --- 3d-viewer/vrmlmodelparser.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/3d-viewer/vrmlmodelparser.cpp b/3d-viewer/vrmlmodelparser.cpp index fa90c6ada8..138dae47da 100644 --- a/3d-viewer/vrmlmodelparser.cpp +++ b/3d-viewer/vrmlmodelparser.cpp @@ -68,6 +68,8 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename ) while( GetLine( file, line, &LineNum, 512 ) ) { text = strtok( line, sep_chars ); + if ( text == NULL ) + continue; if( stricmp( text, "DEF" ) == 0 || stricmp( text, "Group" ) == 0 ) { @@ -371,6 +373,9 @@ int VRML_MODEL_PARSER::readGeometry( FILE* file, int* LineNum ) strcpy( buffer, line ); text = strtok( buffer, sep_chars ); + if( text == NULL ) + continue; + if( *text == '}' ) { err = 0; @@ -381,7 +386,7 @@ int VRML_MODEL_PARSER::readGeometry( FILE* file, int* LineNum ) { text = strtok( NULL, " ,\t\n\r" ); - if( stricmp( text, "true" ) == 0 ) + if( text && stricmp( text, "true" ) == 0 ) { } else @@ -395,7 +400,7 @@ int VRML_MODEL_PARSER::readGeometry( FILE* file, int* LineNum ) { text = strtok( NULL, " ,\t\n\r" ); - if( stricmp( text, "true" ) == 0 ) + if( text && stricmp( text, "true" ) == 0 ) { } else