Module: wine Branch: master Commit: db77f535073b7b9c29d923870104b4bbd86f881f URL: https://source.winehq.org/git/wine.git/?a=commit;h=db77f535073b7b9c29d923870...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Nov 12 20:50:17 2019 +0100
oleaut32: Fix checks for digit characters.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/oleaut32/tests/vartest.c | 6 ++++++ dlls/oleaut32/variant.c | 11 ++++++++--- dlls/oleaut32/vartype.c | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 0b1ac0f1cd..1bd40ac6bc 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -1312,6 +1312,7 @@ static void test_VarParseNumFromStr(void) LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT); NUMPARSE np; BYTE rgb[128]; + WCHAR str[128];
/** No flags **/
@@ -1734,6 +1735,11 @@ static void test_VarParseNumFromStr(void) CONVERT("0.10", NUMPRS_STD); EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1); EXPECT2(1,0); + + str[0] = 0x0660; + str[1] = 0; + hres = pVarParseNumFromStr(str, lcid, LOCALE_NOUSEROVERRIDE, &np, rgb); + ok(hres == DISP_E_TYPEMISMATCH, "VarParseNumFromStr returned %08x\n", hres); }
static HRESULT (WINAPI *pVarNumFromParseNum)(NUMPARSE*,BYTE*,ULONG,VARIANT*); diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index ce96ba1456..36191b6b42 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -1571,6 +1571,11 @@ static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID #define B_PROCESSING_HEX 0x20 #define B_PROCESSING_OCT 0x40
+static inline BOOL is_digit(WCHAR c) +{ + return '0' <= c && c <= '9'; +} + /********************************************************************** * VarParseNumFromStr [OLEAUT32.46] * @@ -1714,14 +1719,14 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
while (*lpszStr) { - if (iswdigit(*lpszStr)) + if (is_digit(*lpszStr)) { if (dwState & B_PROCESSING_EXPONENT) { int exponentSize = 0; if (dwState & B_EXPONENT_START) { - if (!iswdigit(*lpszStr)) + if (!is_digit(*lpszStr)) break; /* No exponent digits - invalid */ while (*lpszStr == '0') { @@ -1731,7 +1736,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags, } }
- while (iswdigit(*lpszStr)) + while (is_digit(*lpszStr)) { exponentSize *= 10; exponentSize += *lpszStr - '0'; diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c index 75d883a909..4201a53642 100644 --- a/dlls/oleaut32/vartype.c +++ b/dlls/oleaut32/vartype.c @@ -7657,7 +7657,7 @@ HRESULT WINAPI VarDateFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, DATE* pd /* Parse the string into our structure */ while (*strIn) { - if (iswdigit(*strIn)) + if ('0' <= *strIn && *strIn <= '9') { if (dp.dwCount >= 6) {