ref: 5a05103353eb4b3c5fa387cfb287b781fd06359b
parent: 0f0cbf03f9dcbee4dba981e29a7ea43d96e648e7
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Sep 7 19:20:17 EDT 2015
Fix readint() There were several errors in the overflow condition and the maximum of the type was not updated in type upgrade.
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -211,9 +211,9 @@
max = (tp->sign) ? lim->max.u : lim->max.i;
- for (u = 0; isxdigit(c = *s++); u = u * base + val) {
+ for (u = 0; isxdigit(c = *s++); u = u*base + val) {
val = (c <= '9') ? c - '0' : 10 + c - 'A';
- if (u <= max/base + val)
+ if (u <= max/base && u*base <= max - val)
continue;
if (tp->sign) {
if (tp == inttype) {
@@ -235,6 +235,7 @@
}
}
sym->type = tp;
+ max = (tp->sign) ? lim->max.u : lim->max.i;
}
if (tp->sign)