Fix misc bad-syntax crashes, bug1530.

This commit is contained in:
Wilson Snyder
2019-09-30 19:48:01 -04:00
parent dd4aa948ae
commit 9eaec3b5c1
5 changed files with 34 additions and 3 deletions
+8 -1
View File
@@ -31,6 +31,7 @@
#include <iomanip>
#define MAX_SPRINTF_DOUBLE_SIZE 100 // Maximum characters with a sprintf %e/%f/%g (probably < 30)
#define MAX_WIDTH 5*1024 // Maximum width before error
// Number operations build output in-place so can't call e.g. foo.opX(foo)
#define NUM_ASSERT_OP_ARGS1(arg1) \
@@ -106,7 +107,13 @@ void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl)
value_startp = cp;
if (atoi(widthn)) {
width(atoi(widthn), true);
if (atoi(widthn) < 0 || atoi(widthn) > MAX_WIDTH) {
// atoi might convert large number to negative, so can't tell which
v3error("Unsupported: Width of number exceeds implementation limit: "<<sourcep);
width(MAX_WIDTH, true);
} else {
width(atoi(widthn), true);
}
}
} else {
unbased = true;