From: Gabe Black Date: Fri, 5 Oct 2018 22:38:23 +0000 (-0700) Subject: systemc: Add an error check to sc_gen_unique_name. X-Git-Tag: v19.0.0.0~1523 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c701d88756fa135c2016cbf968970d37ec67e26c;p=gem5.git systemc: Add an error check to sc_gen_unique_name. Accellera checks for a null pointer, and a test tries using that input. Change-Id: I0f098f53de37ebbe481ea46e61fc0a9a404c29db Reviewed-on: https://gem5-review.googlesource.com/c/13302 Reviewed-by: Gabe Black Maintainer: Gabe Black --- diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc index 175b9db63..0b58f3232 100644 --- a/src/systemc/core/sc_module.cc +++ b/src/systemc/core/sc_module.cc @@ -822,12 +822,20 @@ at_negedge(const sc_signal_in_if &s) const char * sc_gen_unique_name(const char *seed) { + if (!seed || seed[0] == '\0') { + SC_REPORT_ERROR( + "(E532) cannot generate unique name from null string", ""); + seed = "unnamed"; + } + auto mod = sc_gem5::pickParentModule(); if (mod) return mod->uniqueName(seed); + sc_gem5::Process *p = sc_gem5::scheduler.current(); if (p) return p->uniqueName(seed); + return ::sc_gem5::nameGen.gen(seed); }