3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-12-29 23:43:23 +00:00

newcelltypes: bounds check

This commit is contained in:
Emil J. Tywoniak 2025-11-25 19:06:46 +01:00
parent 29453aa053
commit f6e5ea3027

View file

@ -410,7 +410,10 @@ struct Categories {
struct Category {
std::array<bool, MAX_CELLS> data{};
constexpr bool operator()(IdString type) const {
return data[type.index_];
size_t idx = type.index_;
if (idx >= MAX_CELLS)
return false;
return data[idx];
}
constexpr bool& operator[](size_t idx) {
return data[idx];
@ -496,12 +499,14 @@ struct NewCellType {
struct NewCellTypes {
StaticCellTypes::Categories::Category static_cell_types = StaticCellTypes::categories.empty;
dict<RTLIL::IdString, NewCellType> custom_cell_types;
dict<RTLIL::IdString, NewCellType> custom_cell_types = {};
NewCellTypes() {
static_cell_types = StaticCellTypes::categories.empty;
}
NewCellTypes(RTLIL::Design *design) {
static_cell_types = StaticCellTypes::categories.empty;
setup(design);
}
void setup(RTLIL::Design *design = NULL) {