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

@ -1589,6 +1589,8 @@ void SIM_MODEL::InferredReadDataFields( unsigned aSymbolPinCount, const std::vec
ParseParamsField( GetFieldValue( aFields, VALUE_FIELD ) ); ParseParamsField( GetFieldValue( aFields, VALUE_FIELD ) );
} }
catch( const IO_ERROR& e ) catch( const IO_ERROR& e )
{
if( GetParamCount() >= 1 )
{ {
if( aAllowOnlyFirstValue ) if( aAllowOnlyFirstValue )
SetParamValue( 0, parseFieldFloatValue( valueField ) ); SetParamValue( 0, parseFieldFloatValue( valueField ) );
@ -1596,7 +1598,8 @@ void SIM_MODEL::InferredReadDataFields( unsigned aSymbolPinCount, const std::vec
throw e; 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 ) );