Mercurial > hg > index.cgi
changeset 466:51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
You actually need to check if an expression collapsed to an integer before
assuming it is one. Otherwise, you end up assuming everything is 8 bit
offsets. Oops.
author | William Astle <lost@l-w.ca> |
---|---|
date | Wed, 28 Feb 2018 23:35:12 -0700 |
parents | 7370a67caf7e |
children | 7577bfee48bb |
files | lwasm/insn_indexed.c |
diffstat | 1 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/lwasm/insn_indexed.c Wed Feb 28 23:31:17 2018 -0700 +++ b/lwasm/insn_indexed.c Wed Feb 28 23:35:12 2018 -0700 @@ -588,15 +588,18 @@ as -> pretendmax = 1; lwasm_reduce_expr(as, e2); as -> pretendmax = v; - v = lw_expr_intval(e2); - // Actual range is -128 <= offset <= 127; we're allowing a fudge - // factor of 25 or so bytes so that we're less likely to accidentally - // cross into the 16 bit boundary in weird corner cases. - if (v >= -100 || v <= 100) + if (lw_expr_istype(e2, lw_expr_type_int)) { - l -> lint = 1; - l -> pb = (l -> pb & 0x80) ? 0x9C : 0x8C; - return; + v = lw_expr_intval(e2); + // Actual range is -128 <= offset <= 127; we're allowing a fudge + // factor of 25 or so bytes so that we're less likely to accidentally + // cross into the 16 bit boundary in weird corner cases. + if (v >= -100 || v <= 100) + { + l -> lint = 1; + l -> pb = (l -> pb & 0x80) ? 0x9C : 0x8C; + return; + } } } }