[PATCH] Removed unneeded wcscpy_s comparison

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Thu Feb 28 03:37:48 CST 2008


---
 dlls/msvcrt/tests/string.c |    6 ++++++
 dlls/msvcrt/wcs.c          |    5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index 4201c5e..4b54aa3 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -602,6 +602,12 @@ static void test_wcscpy_s(void)
     ret = p_wcscpy_s(szDestShort, 8, szLongText);
     ok(ret == EINVAL, "expected EINVAL got %d\n", ret);
     ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
+    
+    /* Buffer same size as Source string */
+    szDest[0] = 'A';
+    ret = p_wcscpy_s(szDestShort, 16, szLongText);
+    ok(ret == EINVAL, "expected EINVAL got %d\n", ret);
+    ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
 }
 
 START_TEST(string)
diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index c6f3e95..1f296fb 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -996,15 +996,12 @@ INT CDECL MSVCRT_wcscpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, con
 
     size = strlenW(wcSrc) + 1;
 
-    if(size > numElement)
+    if(size >= numElement)
     {
         wcDest[0] = 0;
         return MSVCRT_EINVAL;
     }
 
-    if(size > numElement)
-        size = numElement;
-
     memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
 
     return 0;
-- 
1.5.4.1


--------------010703040405040400060306--




More information about the wine-patches mailing list