# HG changeset patch # User William Astle # Date 1431726446 21600 # Node ID 433851a267943337c6aaac0a777beb580d500041 # Parent e1f4d5af643868f014ac88091be71334a4f116bb Make base prefix sigils error out if no number following Prefix sigils (0x, %, &, @, $) were parsing to 0 if there was no number following the prefix. Make parsing fail if that is the case. Note that in a couple of obscure cases, it may give "undefined symbol" rather than "bad operand" due to some interactions with other unfortunate features of the source format. diff -r e1f4d5af6438 -r 433851a26794 lwasm/lwasm.c --- a/lwasm/lwasm.c Tue Apr 14 08:57:47 2015 -0600 +++ b/lwasm/lwasm.c Fri May 15 15:47:26 2015 -0600 @@ -439,8 +439,13 @@ neg = -1; } - if (!strchr("0123456789", **p)) + if (!**p || !strchr("0123456789", **p)) + { + (*p)--; + if (neg < 0) + (*p)--; return NULL; + } while (**p && strchr("0123456789", **p)) { @@ -463,7 +468,12 @@ } if (**p != '0' && **p != '1') + { + (*p)--; + if (neg < 0) + (*p)--; return NULL; + } while (**p && (**p == '0' || **p == '1')) { @@ -484,9 +494,13 @@ neg = -1; } - if (!strchr("0123456789abcdefABCDEF", **p)) + if (!**p || !strchr("0123456789abcdefABCDEF", **p)) + { + (*p)--; + if (neg < 0) + (*p)--; return NULL; - + } while (**p && strchr("0123456789abcdefABCDEF", **p)) { v2 = toupper(**p) - '0'; @@ -504,9 +518,11 @@ int v = 0, v2; (*p)+=2; - if (!strchr("0123456789abcdefABCDEF", **p)) + if (!**p || !strchr("0123456789abcdefABCDEF", **p)) + { + (*p) -= 2; return NULL; - + } while (**p && strchr("0123456789abcdefABCDEF", **p)) { v2 = toupper(**p) - '0'; @@ -530,9 +546,14 @@ } - if (!strchr("01234567", **p)) + if (!**p || !strchr("01234567", **p)) + { + (*p)--; + if (neg < 0) + (*p)--; return NULL; - + } + while (**p && strchr("01234567", **p)) { v = v * 8 + (**p - '0');