Sim: Fix crash due to accessing param 0 of TYPE::NONE model

This commit is contained in:
Mikolaj Wielgus 2022-09-02 20:19:50 +02:00
parent 20eca94fca
commit cfdf6c097d
1 changed files with 8 additions and 5 deletions

View File

@ -1590,13 +1590,16 @@ void SIM_MODEL::InferredReadDataFields( unsigned aSymbolPinCount, const std::vec
} }
catch( const IO_ERROR& e ) catch( const IO_ERROR& e )
{ {
if( aAllowOnlyFirstValue ) if( GetParamCount() >= 1 )
SetParamValue( 0, parseFieldFloatValue( valueField ) ); {
else if( aAllowOnlyFirstValue )
throw e; SetParamValue( 0, parseFieldFloatValue( valueField ) );
else
throw e;
}
} }
} }
else if( aAllowOnlyFirstValue ) else if( GetParamCount() >= 1 && aAllowOnlyFirstValue )
{ {
// This is reached only when model allows only the first value. // This is reached only when model allows only the first value.
SetParamValue( 0, parseFieldFloatValue( valueField ) ); SetParamValue( 0, parseFieldFloatValue( valueField ) );