3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-14 11:15:40 +00:00

Fixed Overflow error in checking width

This commit is contained in:
Michael Baier 2026-07-09 11:56:21 +02:00
parent 5cd9efefe3
commit eb4e29810e

View file

@ -529,9 +529,10 @@ struct RTLILFrontendWorker {
break;
}
if (try_parse_keyword("width")){
width = parse_integer();
if (width >= RTLIL::WIDTH_LIMIT)
error("Wire width %lld out of range before `%s`.", width, error_token());
long long width_val = parse_integer();
if (width_val < 0 || width_val >= RTLIL::WIDTH_LIMIT)
error("Wire width %lld out of range before `%s`.", width_val, error_token());
width = width_val;
}
else if (try_parse_keyword("upto"))
upto = true;
@ -589,9 +590,10 @@ struct RTLILFrontendWorker {
break;
}
if (try_parse_keyword("width")){
width = parse_integer();
if (width >= RTLIL::WIDTH_LIMIT)
error("Memory width %lld out of range before `%s`.", width, error_token());
long long width_val = parse_integer();
if (width_val < 0 || width_val >= RTLIL::WIDTH_LIMIT)
error("Memory width %lld out of range before `%s`.", width_val, error_token());
width = width_val;
}
else if (try_parse_keyword("size"))
size = parse_integer();