Prevent crash (seg fault), if measure statement is incomplete

This commit is contained in:
Holger Vogt 2023-04-26 17:06:39 +02:00
parent f747f09495
commit 923f7efab0
1 changed files with 30 additions and 0 deletions

View File

@ -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);