usp10/tests: Reserve for InClass a byte for every character in teststr. (v4)

Aric Stewart aric at codeweavers.com
Sun Aug 7 20:21:33 CDT 2016


Signed-off-by: Aric Stewart <aric at codeweavers.com>

On 8/5/16 3:43 PM, Bernhard Übelacker wrote:
> https://bugs.winehq.org/show_bug.cgi?id=40385
> 
> ScriptStringAnalyse expects InClass pointing to an array with one
> byte for every character getting in teststr.
> 
> v1:
> https://www.winehq.org/pipermail/wine-patches/2016-August/153001.html
> https://www.winehq.org/pipermail/wine-devel/2016-August/114173.html
> 
> Changes since v1:
> - Avoid compiler warning by using static with explicit array length.
> - Show trace just when we expect a crash.
> - Check hr if we did not crash.
> 
> v2:
> https://www.winehq.org/pipermail/wine-patches/2016-August/153075.html
> https://www.winehq.org/pipermail/wine-devel/2016-August/114184.html
> 
> Changes since v2:
> - Remove the ugly test with PAGE_NOACCESS and leave just the fix.
> 
> v3:
> https://www.winehq.org/pipermail/wine-patches/2016-August/153134.html
> https://www.winehq.org/pipermail/wine-devel/2016-August/114200.html
> 
> Changes since v3:
> - Replace explicit array size to sizeof() kind.
> - Dx array needs also the size of the length of the string.
> 
> Thanks to all reviewers.
> 
> Signed-off-by: Bernhard Übelacker <bernhardu at mailbox.org>
> ---
>  dlls/usp10/tests/usp10.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
> index 6b2152f..aed0620 100644
> --- a/dlls/usp10/tests/usp10.c
> +++ b/dlls/usp10/tests/usp10.c
> @@ -2899,8 +2899,8 @@ static void test_ScriptString(HDC hdc)
>      int             Charset;
>      DWORD           Flags = SSA_GLYPHS;
>      int             ReqWidth = 100;
> -    const int       Dx[5] = {10, 10, 10, 10, 10};
> -    const BYTE      InClass = 0;
> +    static const int Dx[(sizeof(teststr) / sizeof(WCHAR)) - 1];
> +    static const BYTE InClass[(sizeof(teststr) / sizeof(WCHAR)) - 1];
>      SCRIPT_STRING_ANALYSIS ssa = NULL;
>  
>      int             X = 10; 
> @@ -2919,26 +2919,26 @@ static void test_ScriptString(HDC hdc)
>      /* Test without hdc to get E_PENDING */
>      hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
>                                ReqWidth, NULL, NULL, Dx, NULL,
> -                              &InClass, &ssa);
> +                              InClass, &ssa);
>      ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
>  
>      /* Test that 0 length string returns E_INVALIDARG  */
>      hr = ScriptStringAnalyse( hdc, teststr, 0, Glyphs, Charset, Flags,
>                                ReqWidth, NULL, NULL, Dx, NULL,
> -                              &InClass, &ssa);
> +                              InClass, &ssa);
>      ok(hr == E_INVALIDARG, "ScriptStringAnalyse should return E_INVALIDARG not %08x\n", hr);
>  
>      /* test with hdc, this should be a valid test  */
>      hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
>                                ReqWidth, NULL, NULL, Dx, NULL,
> -                              &InClass, &ssa);
> +                              InClass, &ssa);
>      ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
>      ScriptStringFree(&ssa);
>  
>      /* test makes sure that a call with a valid pssa still works */
>      hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
>                                ReqWidth, NULL, NULL, Dx, NULL,
> -                              &InClass, &ssa);
> +                              InClass, &ssa);
>      ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
>      ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
>  
> @@ -2982,7 +2982,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
>      int             Charset = -1;                       /* unicode                        */
>      DWORD           Flags = SSA_GLYPHS;
>      int             ReqWidth = 100;
> -    const BYTE      InClass = 0;
> +    static const BYTE InClass[(sizeof(teststr1)/sizeof(WCHAR))-1];
>      SCRIPT_STRING_ANALYSIS ssa = NULL;
>  
>      int             Ch;                                  /* Character position in string */
> @@ -2999,7 +2999,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
>  
>      hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
>                                ReqWidth, NULL, NULL, NULL, NULL,
> -                              &InClass, &ssa);
> +                              InClass, &ssa);
>      ok(hr == S_OK ||
>         hr == E_INVALIDARG, /* NT */
>         "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr);
> @@ -3139,7 +3139,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
>           */
>          hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
>                                    ReqWidth, NULL, NULL, NULL, NULL,
> -                                  &InClass, &ssa);
> +                                  InClass, &ssa);
>          ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
>  
>          /*
> 



More information about the wine-patches mailing list