Commit 25bbc7e9 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Fix error handling in _mbsupr_s_l.

parent 71144728
......@@ -2194,15 +2194,12 @@ unsigned char* CDECL _mbsupr(unsigned char* s)
*/
int CDECL _mbsupr_s_l(unsigned char* s, size_t len, _locale_t locale)
{
unsigned char *p = s;
if (!s && !len)
{
return 0;
}
else if (!s || !len)
{
*_errno() = EINVAL;
if (!MSVCRT_CHECK_PMT(s && len))
return EINVAL;
}
if (get_mbcinfo()->ismbcodepage)
{
......@@ -2225,12 +2222,12 @@ int CDECL _mbsupr_s_l(unsigned char* s, size_t len, _locale_t locale)
*s = _toupper_l(*s, locale);
}
if (*s)
if (!MSVCRT_CHECK_PMT(len))
{
*s = '\0';
*_errno() = EINVAL;
*p = 0;
return EINVAL;
}
*s = 0;
return 0;
}
......
......@@ -2879,7 +2879,7 @@ static void test__mbsupr_s(void)
memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
errno = EBADF;
ret = p_mbsupr_s(buffer, 4);
ret = p_mbsupr_s(buffer, sizeof("abcdefgh") - 1);
ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment