From 923f7efab0df280bd056557ad12c5e06525876f9 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 26 Apr 2023 17:06:39 +0200 Subject: [PATCH] Prevent crash (seg fault), if measure statement is incomplete --- src/frontend/measure.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/frontend/measure.c b/src/frontend/measure.c index 9ca735a3f..c91715a11 100644 --- a/src/frontend/measure.c +++ b/src/frontend/measure.c @@ -283,6 +283,22 @@ do_measure( resname = gettok(&line); meastype = gettok(&line); + if (!an_type){ + fprintf(cp_err, "\nWarning: Incomplete measurement statement in line\n %s\nignored!\n", meas_card->line); + continue; + } + if (!resname){ + fprintf(cp_err, "\nWarning: Incomplete measurement statement in line\n %s\nignored!\n", meas_card->line); + tfree(an_type); + continue; + } + if (!meastype) { + fprintf(cp_err, "\nWarning: Incomplete measurement statement in line\n %s\nignored!\n", meas_card->line); + tfree(an_type); + tfree(resname); + continue; + } + if (chkAnalysisType(an_type) != TRUE) { if (!chk_only) { fprintf(cp_err, "Error: unrecognized analysis type '%s' for the following .meas statement on line %d:\n", an_type, meas_card->linenum); @@ -399,6 +415,20 @@ do_measure( resname = gettok(&line); meastype = gettok(&line); + if (!an_type) { + /* Warnings have already been issued in first pass */ + continue; + } + if (!resname) { + tfree(an_type); + continue; + } + if (!meastype) { + tfree(an_type); + tfree(resname); + continue; + } + if (chkAnalysisType(an_type) != TRUE) { if (!chk_only) { fprintf(cp_err, "Error: unrecognized analysis type '%s' for the following .meas statement on line %d:\n", an_type, meas_card->linenum);