From 4fff1424448584da5aa0a352cff88ab989562007 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 11 Jun 2018 02:35:07 -0700 Subject: [PATCH] SCP: Fix EXPECT bookkeeping to avoid reference after free error --- scp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scp.c b/scp.c index 273066b8..ebcbf226 100644 --- a/scp.c +++ b/scp.c @@ -11819,6 +11819,9 @@ if (i != exp->size) { /* Found? */ ep->cnt, (ep->cnt == 1) ? "" : "es"); } else { + uint32 after = ep->after; + int32 switches = ep->switches; + if (ep->act && *ep->act) { sim_debug (exp->dbit, exp->dptr, "Initiating actions: %s\n", ep->act); } @@ -11833,9 +11836,9 @@ if (i != exp->size) { /* Found? */ sim_exp_clr_tab (exp, ep); /* delete it */ } sim_activate (&sim_expect_unit, /* schedule simulation stop when indicated */ - (ep->switches & EXP_TYP_TIME) ? - (int32)((sim_timer_inst_per_sec ()*ep->after)/1000000.0) : - ep->after); + (switches & EXP_TYP_TIME) ? + (int32)((sim_timer_inst_per_sec ()*after)/1000000.0) : + after); } /* Matched data is no longer available for future matching */ exp->buf_data = exp->buf_ins = 0;