[PATCH] msvcrt/tests: Add tests for mbstowcs and wcstombs with a negative count.

Alex Henrie alexhenrie24 at gmail.com
Mon Jun 13 23:18:15 CDT 2016


2016-06-13 8:56 GMT-06:00 Alex Henrie <alexhenrie24 at gmail.com>:
> 2016-06-13 4:21 GMT-06:00 Piotr Caban <piotr.caban at gmail.com>:
>> I'm also not sure if Windows XP behavior should be marked as broken. For me
>> newer systems behavior is broken (doesn't handle strings longer then
>> INT_MAX). Do you have an application that depends on it?
>
> I discovered this while trying to figure out what's wrong with the
> Emergency 3 Demo: https://bugs.winehq.org/show_bug.cgi?id=40775
>
> The bug would be "fixed" if we adopted the Windows XP behavior for
> mbstowcs. However, this application works fine on both Windows XP and
> Windows 7, so I think that there is actually something else going on
> here.
>
> I really don't know which behavior should be considered "correct".
> Windows XP's behavior matches the C specification, but Vista and later
> all consistently do something else. Maybe we should make Wine behave
> differently too depending on which version of Windows is selected in
> winecfg, and put "ret == 4 || ret == -1" in the tests, omitting the
> broken() macro. What do you think?

I just ran some more tests, and it turns out that the behavior of
Vista and later is even weirder than I thought. On these systems,
mbstowcs with a negative count writes one null byte to the output
string before returning -1, but wcstombs returns -1 without writing
anything.

I think I'd rather have the Windows XP / standard C behavior than the
inconsistent, nonconformant Vista behavior.

-Alex



More information about the wine-devel mailing list