aboutsummaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorAki Van Ness <aki@yosyshq.com>2023-02-01 10:15:20 -0500
committerAki <201479+lethalbit@users.noreply.github.com>2023-02-03 08:27:52 -0500
commita90f9406155aafb4becc43fb21c75ab3aff9bdd7 (patch)
treeb29b9c3c13ece110d813a4d32ebdc27ddc9c0d55 /backends
parent221036c5b69a7298b5363c384e40f507b08dd179 (diff)
downloadyosys-a90f9406155aafb4becc43fb21c75ab3aff9bdd7.tar.gz
yosys-a90f9406155aafb4becc43fb21c75ab3aff9bdd7.tar.bz2
yosys-a90f9406155aafb4becc43fb21c75ab3aff9bdd7.zip
backends/firrtl: Ensure `modInstance` is valid
This should fix #3648 where when calling `emit_elaborated_extmodules` it checks to see if a module is a black-box, however there was no validation that the cell type was actually known, and it just always assumed that we would get a valid instance, causing a segfault.
Diffstat (limited to 'backends')
-rw-r--r--backends/firrtl/firrtl.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/backends/firrtl/firrtl.cc b/backends/firrtl/firrtl.cc
index d68c52563..eb30ab4b9 100644
--- a/backends/firrtl/firrtl.cc
+++ b/backends/firrtl/firrtl.cc
@@ -346,6 +346,12 @@ void emit_elaborated_extmodules(RTLIL::Design *design, std::ostream &f)
{
// Find the module corresponding to this instance.
auto modInstance = design->module(cell->type);
+ // Ensure that we actually have a module instance
+ if (modInstance == nullptr) {
+ log_error("Unknown cell type %s\n", cell->type.c_str());
+ return;
+ }
+
bool modIsBlackbox = modInstance->get_blackbox_attribute();
if (modIsBlackbox)