From 0609d231c0e450ac09e7fa23f6327beb4dd4898f Mon Sep 17 00:00:00 2001 From: h_vogt Date: Wed, 29 Jan 2014 21:21:16 +0100 Subject: [PATCH] runcoms2.c: prevent crash after 'remcirc' if no circuit is loaded --- src/frontend/runcoms2.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index 024cc6259..aa8c223b1 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -200,14 +200,8 @@ com_remcirc(wordlist *wl) struct variable *v, *next; struct line *dd; /*in: the spice deck */ struct circ *p, *prev = NULL; - #ifdef SHARED_MODULE - /* This may happen only with shared ngspice during transient analysis, - if simulation is stopped with 'bg_halt' - and then circuit shall be removed prematurely. */ - TRANan *job = (TRANan *) ft_curckt->ci_ckt->CKTcurJob; - if ((job->JOBtype == 4) && (job->TRANplot)) - SPfrontEnd->OUTendPlot (job->TRANplot); + TRANan *job; #endif NG_IGNORE(wl); @@ -217,6 +211,15 @@ com_remcirc(wordlist *wl) return; } +#ifdef SHARED_MODULE + /* This may happen only with shared ngspice during transient analysis, + if simulation is stopped with 'bg_halt' + and then circuit shall be removed prematurely. */ + job = (TRANan *) ft_curckt->ci_ckt->CKTcurJob; + if (job && (job->JOBtype == 4) && (job->TRANplot)) + SPfrontEnd->OUTendPlot (job->TRANplot); +#endif + /* delete numparam data structure dicoS */ nupa_del_dicoS();