Jacek Caban : jscript: Better handling of to_integer result in String. charCodeAt.
Alexandre Julliard
julliard at winehq.org
Thu May 3 14:23:49 CDT 2012
Module: wine
Branch: master
Commit: 621180e81c260af68a28fcd793a1d4352eccac1c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=621180e81c260af68a28fcd793a1d4352eccac1c
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu May 3 10:40:27 2012 +0200
jscript: Better handling of to_integer result in String.charCodeAt.
---
dlls/jscript/string.c | 10 +++++++---
dlls/jscript/tests/api.js | 2 ++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index bf9312d..9f6dc4f 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -350,6 +350,7 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if(arg_cnt(dp) > 0) {
VARIANT v;
+ double d;
hres = to_integer(ctx, get_arg(dp, 0), ei, &v);
if(FAILED(hres)) {
@@ -357,13 +358,16 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return hres;
}
- if(V_VT(&v) != VT_I4 || V_I4(&v) < 0 || V_I4(&v) >= length) {
- if(retv) num_set_nan(&v);
+ d = num_val(&v);
+
+ if(!is_int32(d) || d < 0 || d >= length) {
SysFreeString(val_str);
+ if(retv)
+ num_set_nan(retv);
return S_OK;
}
- idx = V_I4(&v);
+ idx = d;
}
if(retv) {
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index f92cd48..861019f 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -329,6 +329,8 @@ tmp = "\052".charCodeAt(0);
ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
tmp = "\xa2".charCodeAt(0);
ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
+tmp = "abc".charCodeAt(bigInt);
+ok(isNaN(tmp), "'abc'.charCodeAt(bigInt) = " + tmp);
tmp = "abcd".substring(1,3);
ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
More information about the wine-cvs
mailing list