jscript: Properly parse large hexadecimal listerals.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-04-11 19:36:11 +02:00 committed by Alexandre Julliard
parent f96aa1f32c
commit 4fde6d4138
2 changed files with 7 additions and 4 deletions

View File

@ -487,18 +487,18 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
HRESULT hres; HRESULT hres;
if(*ctx->ptr == '0') { if(*ctx->ptr == '0') {
LONG d, l = 0;
ctx->ptr++; ctx->ptr++;
if(*ctx->ptr == 'x' || *ctx->ptr == 'X') { if(*ctx->ptr == 'x' || *ctx->ptr == 'X') {
double r = 0;
int d;
if(++ctx->ptr == ctx->end) { if(++ctx->ptr == ctx->end) {
ERR("unexpected end of file\n"); ERR("unexpected end of file\n");
return FALSE; return FALSE;
} }
while(ctx->ptr < ctx->end && (d = hex_to_int(*ctx->ptr)) != -1) { while(ctx->ptr < ctx->end && (d = hex_to_int(*ctx->ptr)) != -1) {
l = l*16 + d; r = r*16 + d;
ctx->ptr++; ctx->ptr++;
} }
@ -508,7 +508,7 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
return FALSE; return FALSE;
} }
*ret = l; *ret = r;
return TRUE; return TRUE;
} }

View File

@ -48,6 +48,9 @@ tmp = 07777777777777777777777;
ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp); ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
tmp = 07777777779777777777777; tmp = 07777777779777777777777;
ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp); ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
ok(0xffffffff === 4294967295, "0xffffffff = " + 0xffffffff);
tmp = 0x10000000000000000000000000000000000000000000000000000000000000000;
ok(tmp === Math.pow(2, 256), "0x1000...00 != 2^256");
ok(1 !== 2, "1 !== 2 is false"); ok(1 !== 2, "1 !== 2 is false");
ok(null !== undefined, "null !== undefined is false"); ok(null !== undefined, "null !== undefined is false");