Prevent a crash when "portnum" is used in a voltage source without "z0".

This commit is contained in:
Giles Atkinson 2023-03-06 11:53:36 +00:00 committed by Holger Vogt
parent 8915d42241
commit ae6375c519
1 changed files with 8 additions and 3 deletions

View File

@ -298,14 +298,19 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
{
here->VSRCportNum = value->iValue;
here->VSRCportNumGiven = TRUE;
here->VSRCisPort = ((here->VSRCportNumGiven) && (here->VSRCportNum > 0) && (here->VSRCportZ0 > 0.0));
here->VSRCisPort = (here->VSRCportNum > 0);
if (here->VSRCportZ0 <= 0.0) {
here->VSRCportZ0 = 50;
here->VSRCVAmplitude =
sqrt(here->VSRCportPower * 4.0 * here->VSRCportZ0);
}
break;
}
case VSRC_PORTZ0:
{
here->VSRCportZ0 = value->rValue;
here->VSRCVAmplitude = sqrt(here->VSRCportPower * 4.0 * here->VSRCportZ0);
here->VSRCisPort = ((here->VSRCportNumGiven) && (here->VSRCportNum > 0) && (here->VSRCportZ0 > 0.0));
here->VSRCVAmplitude =
sqrt(here->VSRCportPower * 4.0 * here->VSRCportZ0);
here->VSRCportZ0Given = TRUE;
break;
}