1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

Fix final valgrind errors with #830. Catch mb conversion error that may not

terminate correctly.
Jeremy.
(This used to be commit 49142c6352)
This commit is contained in:
Jeremy Allison 2004-02-04 20:28:51 +00:00
parent 471e558b28
commit da371e74bb

View File

@ -1293,6 +1293,8 @@ char *strnrchr_m(const char *s, char c, unsigned int n)
void strlower_m(char *s) void strlower_m(char *s)
{ {
size_t len;
/* this is quite a common operation, so we want it to be /* this is quite a common operation, so we want it to be
fast. We optimise for the ascii case, knowing that all our fast. We optimise for the ascii case, knowing that all our
supported multi-byte character sets are ascii-compatible supported multi-byte character sets are ascii-compatible
@ -1308,7 +1310,12 @@ void strlower_m(char *s)
/* I assume that lowercased string takes the same number of bytes /* I assume that lowercased string takes the same number of bytes
* as source string even in UTF-8 encoding. (VIV) */ * as source string even in UTF-8 encoding. (VIV) */
unix_strlower(s,strlen(s)+1,s,strlen(s)+1); len = strlen(s) + 1;
errno = 0;
unix_strlower(s,len,s,len);
/* Catch mb conversion errors that may not terminate. */
if (errno)
s[len-1] = '\0';
} }
/** /**
@ -1317,6 +1324,8 @@ void strlower_m(char *s)
void strupper_m(char *s) void strupper_m(char *s)
{ {
size_t len;
/* this is quite a common operation, so we want it to be /* this is quite a common operation, so we want it to be
fast. We optimise for the ascii case, knowing that all our fast. We optimise for the ascii case, knowing that all our
supported multi-byte character sets are ascii-compatible supported multi-byte character sets are ascii-compatible
@ -1332,7 +1341,12 @@ void strupper_m(char *s)
/* I assume that lowercased string takes the same number of bytes /* I assume that lowercased string takes the same number of bytes
* as source string even in multibyte encoding. (VIV) */ * as source string even in multibyte encoding. (VIV) */
unix_strupper(s,strlen(s)+1,s,strlen(s)+1); len = strlen(s) + 1;
errno = 0;
unix_strupper(s,len,s,len);
/* Catch mb conversion errors that may not terminate. */
if (errno)
s[len-1] = '\0';
} }
/** /**