Commit bbd0e56a authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msvcrt: Handle NULL arguments in _mbscmp.

parent 07520fbf
......@@ -24,6 +24,7 @@
*/
#include <stdio.h>
#include <limits.h>
#include "msvcrt.h"
#include "wine/unicode.h"
......@@ -769,6 +770,8 @@ unsigned char* CDECL _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSV
*/
int CDECL _mbscmp(const unsigned char* str, const unsigned char* cmp)
{
if (!str || !cmp) return INT_MAX;
if(get_mbcinfo()->ismbcodepage)
{
unsigned int strc, cmpc;
......
......@@ -2874,6 +2874,36 @@ static void test__wcsset_s(void)
ok(str[2] == 'b', "str[2] = %d\n", str[2]);
}
static void test__mbscmp(void)
{
static const unsigned char a[] = {'a',0}, b[] = {'b',0};
int ret;
if (!p_mbrlen)
{
win_skip("_mbscmp tests\n");
return;
}
ret = _mbscmp(NULL, NULL);
ok(ret == INT_MAX, "got %d\n", ret);
ret = _mbscmp(a, NULL);
ok(ret == INT_MAX, "got %d\n", ret);
ret = _mbscmp(NULL, a);
ok(ret == INT_MAX, "got %d\n", ret);
ret = _mbscmp(a, a);
ok(!ret, "got %d\n", ret);
ret = _mbscmp(a, b);
ok(ret == -1, "got %d\n", ret);
ret = _mbscmp(b, a);
ok(ret == 1, "got %d\n", ret);
}
START_TEST(string)
{
char mem[100];
......@@ -2981,4 +3011,5 @@ START_TEST(string)
test_strxfrm();
test__strnset_s();
test__wcsset_s();
test__mbscmp();
}
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