mirror of
https://git.code.sf.net/p/ngspice/ngspice
synced 2026-09-04 19:10:57 +02:00
coefficient list) one element at a time, calling askInstanceQuest for
every element. Two bugs made that catastrophic on a large chip:
* IFvalue val was uninitialised, so a query that did not set
v.numValue left `n' as stack garbage -- the element loop then ran
essentially forever.
* askInstanceQuest TMALLOCs the coefficient vector (vsrcask.c) on
every call and printvals()/printvals_old() never freed it, so the
listing leaked O(n^2) allocations -- tens of GB on a deck with many
stimulus sources.
Fix: memset val before the query and clamp n (kills the runaway loop),
and free the returned vector after use via a new free_if_vec() helper.
Verified: pulse coefficients still print correctly; show on MOS/BSIM4/
OSDI/vsource is unchanged and does not crash.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>