diff --git a/jsrun.c b/jsrun.c index 113db4a..5e70684 100644 --- a/jsrun.c +++ b/jsrun.c @@ -444,6 +444,11 @@ void js_rot(js_State *J, int n) int js_isarrayindex(js_State *J, const char *p, int *idx) { int n = 0; + + /* check for '0' and integers with leading zero */ + if (p[0] == '0') + return (p[1] == 0) ? *idx = 0, 1 : 0; + while (*p) { int c = *p++; if (c >= '0' && c <= '9') {