Author: gschneider
Date: Mon Aug 3 18:15:40 2009
New Revision: 42363
URL:
http://svn.reactos.org/svn/reactos?rev=42363&view=rev
Log:
- Fix mbslwr: increment pointer in both cases (prevents infinite loops)
- Check for null character pointers, apply somewhat readable formatting
- Add some useful header information
See issue #4755 for more details.
Modified:
trunk/reactos/lib/sdk/crt/mbstring/mbslwr.c
Modified: trunk/reactos/lib/sdk/crt/mbstring/mbslwr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/mbslw…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/mbslwr.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/mbslwr.c [iso-8859-1] Mon Aug 3 18:15:40 2009
@@ -1,12 +1,10 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/sdk/crt/mbstring/ismbpun.c
- * PURPOSE:
- * PROGRAMER:
- * UPDATE HISTORY:
- * 05/30/08: Samuel Serapion adapted from PROJECT C Library
- *
+ * FILE: lib/sdk/crt/mbstring/mbslwr.c
+ * PURPOSE: Multibyte lowercase functions
+ * PROGRAMER: Eric Kohl
+ * Samuel Serapion, adapted from PROJECT C Library
*/
#include <precomp.h>
@@ -33,14 +31,24 @@
*/
unsigned char * _mbslwr(unsigned char *x)
{
- unsigned char *y=x;
+ unsigned char *y=x;
- while (*y) {
- if (!_ismbblead(*y)) {
+ if (x == NULL)
+ {
+ return NULL;
+ }
+
+ while (*y)
+ {
+ if (!_ismbblead(*y))
+ {
*y = tolower(*y);
- } else {
- *y=_mbctolower(*(unsigned short *)y);
- y++;
+ y++;
+ }
+ else
+ {
+ *y = _mbctolower(*(unsigned short *)y);
+ y++;
}
}
return x;