Jacek Caban : jscript: Properly parse large hexadecimal listerals.
Alexandre Julliard
julliard at winehq.org
Wed Apr 11 16:12:55 CDT 2018
Module: wine
Branch: master
Commit: 4fde6d413862b0510ff68ecdb0804e292f6e3104
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4fde6d413862b0510ff68ecdb0804e292f6e3104
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Apr 11 19:36:11 2018 +0200
jscript: Properly parse large hexadecimal listerals.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/lex.c | 8 ++++----
dlls/jscript/tests/lang.js | 3 +++
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c
index b4f6d95..b4cc82a 100644
--- a/dlls/jscript/lex.c
+++ b/dlls/jscript/lex.c
@@ -487,18 +487,18 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
HRESULT hres;
if(*ctx->ptr == '0') {
- LONG d, l = 0;
-
ctx->ptr++;
if(*ctx->ptr == 'x' || *ctx->ptr == 'X') {
+ double r = 0;
+ int d;
if(++ctx->ptr == ctx->end) {
ERR("unexpected end of file\n");
return FALSE;
}
while(ctx->ptr < ctx->end && (d = hex_to_int(*ctx->ptr)) != -1) {
- l = l*16 + d;
+ r = r*16 + d;
ctx->ptr++;
}
@@ -508,7 +508,7 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
return FALSE;
}
- *ret = l;
+ *ret = r;
return TRUE;
}
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 9350200..e6ff4dd 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -48,6 +48,9 @@ tmp = 07777777777777777777777;
ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
tmp = 07777777779777777777777;
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(null !== undefined, "null !== undefined is false");
More information about the wine-cvs
mailing list