From 9d8f60cf818cfea0648cb693ef5642e9f30da3af Mon Sep 17 00:00:00 2001 From: Gregor Schneider Date: Mon, 3 Aug 2009 16:15:40 +0000 Subject: [PATCH] - 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. svn path=/trunk/; revision=42363 --- reactos/lib/sdk/crt/mbstring/mbslwr.c | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/reactos/lib/sdk/crt/mbstring/mbslwr.c b/reactos/lib/sdk/crt/mbstring/mbslwr.c index d2ad5bcc3e2..10d5e11296c 100644 --- a/reactos/lib/sdk/crt/mbstring/mbslwr.c +++ b/reactos/lib/sdk/crt/mbstring/mbslwr.c @@ -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 @@ -33,14 +31,24 @@ unsigned int _mbctolower(unsigned int c) */ 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;