branch update for HEAD-2003021201
[reactos.git] / ntoskrnl / rtl / wstring.c
index f449ca9..ee647f5 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id$
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/rtl/wstring.c
@@ -62,7 +63,7 @@ wchar_t *_wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill)
 {
        wchar_t *t = wsToFill;
        int i = 0;
-       while( *wsToFill != 0 && i < sizeMaxFill)
+       while( *wsToFill != 0 && i < (int) sizeMaxFill)
        {
                *wsToFill = wcFill;
                wsToFill++;
@@ -134,8 +135,6 @@ wchar_t * wcschr(const wchar_t *str, wchar_t ch)
   return NULL;
 }
 
-#ifndef LIBCAPTIVE
-
 int wcscmp(const wchar_t *cs, const wchar_t *ct)
 {
   while (*cs != '\0' && *ct != '\0' && *cs == *ct)
@@ -146,12 +145,11 @@ int wcscmp(const wchar_t *cs, const wchar_t *ct)
   return *cs - *ct;
 }
 
-#endif /* LIBCAPTIVE */
-
 wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
 {
    wchar_t* s = str1;
-   DPRINT("wcscpy(str1 %S, str2 %S)\n",str1,str2);
+   /* Never dump 'str1' here as it can crash due to unitialized memory access (no end-terminator). */
+   DPRINT("wcscpy(str1 <undef>, str2 %S)\n",str2);
    while ((*str2)!=0)
      {
        *s = *str2;
@@ -201,7 +199,7 @@ size_t wcslen(const wchar_t *s)
 
 wchar_t * wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
 {
-  int i, j;
+  unsigned int i, j;
    
   for (j = 0; dest[j] != 0; j++)
     ;
@@ -232,7 +230,7 @@ int wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
 
 wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
 {
-  int i;
+  unsigned int i;
    
   for (i = 0; i < count; i++)
     {
@@ -242,7 +240,6 @@ wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
           return dest;
         }
     }
-  dest[i] = 0;
 
   return dest;
 }