From 20a969bf386db85e043c8aa0062562f030a8070e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 19 Jun 2026 21:43:33 -0700 Subject: [PATCH] Handle invalid old-style UDP tables An empty old-style UDP table leaves the parsed table pointer unset after the parser reports the table error. The old-style UDP creation path still passed the null pointer to process_udp_table(), which crashes. Report an invalid UDP table instead and do not register the primitive. Also keep the new-style invalid-table diagnostic formatting consistent. Signed-off-by: Lars-Peter Clausen --- ivtest/gold/br_gh1175c.gold | 1 - ivtest/gold/br_gh1175d.gold | 1 - ivtest/gold/br_gh1175e.gold | 1 - pform.cc | 16 ++++++++++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ivtest/gold/br_gh1175c.gold b/ivtest/gold/br_gh1175c.gold index 6396fbcf3..3fe2d3526 100644 --- a/ivtest/gold/br_gh1175c.gold +++ b/ivtest/gold/br_gh1175c.gold @@ -1,4 +1,3 @@ ./ivltests/br_gh1175c.v:3: syntax error ./ivltests/br_gh1175c.v:3: errors in UDP table ./ivltests/br_gh1175c.v:1: error: Invalid table for UDP primitive id_0. - diff --git a/ivtest/gold/br_gh1175d.gold b/ivtest/gold/br_gh1175d.gold index 6c42835a7..02daa6584 100644 --- a/ivtest/gold/br_gh1175d.gold +++ b/ivtest/gold/br_gh1175d.gold @@ -1,4 +1,3 @@ ./ivltests/br_gh1175d.v:3: syntax error ./ivltests/br_gh1175d.v:3: errors in UDP table ./ivltests/br_gh1175d.v:1: error: Invalid table for UDP primitive id_0. - diff --git a/ivtest/gold/br_gh1175e.gold b/ivtest/gold/br_gh1175e.gold index 349b984e1..8ee414e94 100644 --- a/ivtest/gold/br_gh1175e.gold +++ b/ivtest/gold/br_gh1175e.gold @@ -1,4 +1,3 @@ ./ivltests/br_gh1175e.v:3: syntax error ./ivltests/br_gh1175e.v:3: errors in UDP table ./ivltests/br_gh1175e.v:1: error: Invalid table for UDP primitive id_0. - diff --git a/pform.cc b/pform.cc index 0a62724e8..59e264326 100644 --- a/pform.cc +++ b/pform.cc @@ -2079,10 +2079,18 @@ void pform_make_udp(const struct vlltype&loc, perm_string name, for (unsigned idx = 0 ; idx < pins.size() ; idx += 1) udp->ports[idx] = pins[idx]->basename(); - process_udp_table(udp, table, loc); - udp->initial = init; + if (table) { + process_udp_table(udp, table, loc); + udp->initial = init; - pform_primitives[name] = udp; + pform_primitives[name] = udp; + } else { + ostringstream msg; + msg << "error: Invalid table for UDP primitive " << name + << "."; + VLerror(loc, msg.str().c_str(), ""); + delete udp; + } } @@ -2172,7 +2180,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name, } else { ostringstream msg; msg << "error: Invalid table for UDP primitive " << name - << "." << endl; + << "."; // Some compilers warn if there is just a single C string. VLerror(loc, msg.str().c_str(), ""); }