Dmitry Kislyuk : vbscript: Return correct error for null start in InStr and more tests.
Alexandre Julliard
julliard at winehq.org
Thu Aug 6 16:33:45 CDT 2020
Module: wine
Branch: master
Commit: 120b2209794f346c072f5064e97b54c3378c329f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=120b2209794f346c072f5064e97b54c3378c329f
Author: Dmitry Kislyuk <dimaki at rocketmail.com>
Date: Wed Aug 5 14:53:31 2020 -0500
vbscript: Return correct error for null start in InStr and more tests.
Signed-off-by: Dmitry Kislyuk <dimaki at rocketmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/vbscript/global.c | 3 +++
dlls/vbscript/tests/api.vbs | 28 ++++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index abb4b7933b..414ede5ed0 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -1662,6 +1662,9 @@ static HRESULT Global_InStr(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
}
if(startv) {
+ if(V_VT(startv) == VT_NULL)
+ return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
+
hres = to_int(startv, &start);
if(FAILED(hres))
return hres;
diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs
index 0c37c3c843..f829afc101 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -435,6 +435,34 @@ Call ok(x = 3, "InStr returned " & x)
x = InStr(1, "23456", 34, 1)
Call ok(x = 2, "InStr returned " & x)
+x = InStr(2, "", "abcd", 0)
+Call ok(x = 0, "InStr returned " & x)
+
+x = InStr(4, "abcdef", "", 0)
+Call ok(x = 4, "InStr returned " & x)
+
+x = InStr(20, "abcdef", "", 0)
+Call ok(x = 0, "InStr returned " & x)
+
+x = InStr(4, "", "", 0)
+Call ok(x = 0, "InStr returned " & x)
+
+Sub testInStrError(arg1, arg2, arg3, arg4, error_num)
+ on error resume next
+ Dim x
+
+ Call Err.clear()
+ x = InStr(arg1, arg2, arg3, arg4)
+ Call ok(Err.number = error_num, "Err.number = " & Err.number)
+End Sub
+
+call testInStrError(2, "abcd", null, 0, 0)
+call testInStrError(2, Null, "abcd", 0, 0)
+call testInStrError(Null, "abcd", "abcd", 0, 94)
+call testInStrError(2, "abcd", "abcd", null, 94)
+call testInStrError(-20, "abcd", "abcd", 1, 5)
+Call testInStrError(2, "abcd", "abcd", 10, 5)
+
x = InStrRev("bcabcd", "bc")
Call ok(x = 4, "InStrRev returned " & x)
More information about the wine-cvs
mailing list