"Alistair Leslie-Hughes" leslie_alistair@hotmail.com writes:
Is there any thing wrong with this patch?
- /* Test invalid size */
- szDest[0] = 'A';
- ret = p_wcscpy_s(szDest, 0, szLongText);
- ok(ret == EINVAL, "expected ERANGE got %d\n", ret);
- ok(szDest[0] == 0, "szDest[0] not 0\n");
- /* Copy same buffer size */
- ret = p_wcscpy_s(szDest, 18, szLongText);
- ok(ret == 0, "expected 0 got %d\n", ret);
- ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n");
- /* Copy smaller buffer size */
- szDest[0] = 'A';
- ret = p_wcscpy_s(szDestShort, 8, szLongText);
- ok(ret == ERANGE, "expected EINVAL got %d\n", ret);
- ok(szDestShort[0] == 0, "szDest[0] not 0\n");
The error messages don't match the tests.
- if(numElement <= 0)
- {
wcDest[0] = 0;
if(numElement < 0)
return ERANGE;
else
return EINVAL;
The variable is unsigned so the comparison is useless. Also its type should be MSVCRT_size_t.