diff options
author | Gerald Carter <jerry@samba.org> | 2000-08-10 14:00:05 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2000-08-10 14:00:05 +0000 |
commit | cfa4c878a2ccaf346940f8f4a201737e185f76d6 (patch) | |
tree | 99f9bcc4158e8f433524a2d898cc4ac4dcb7776a /source/lib/util_unistr.c | |
parent | df51dc32f6ffc4fe2cebfaae5079417aad1ff34d (diff) | |
download | samba-cfa4c878a2ccaf346940f8f4a201737e185f76d6.tar.gz samba-cfa4c878a2ccaf346940f8f4a201737e185f76d6.tar.xz samba-cfa4c878a2ccaf346940f8f4a201737e185f76d6.zip |
Deal will NULL UNISTR in unistr_to_ascii
jerry
Diffstat (limited to 'source/lib/util_unistr.c')
-rw-r--r-- | source/lib/util_unistr.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/source/lib/util_unistr.c b/source/lib/util_unistr.c index 42f1dc0644a..0817dcf072f 100644 --- a/source/lib/util_unistr.c +++ b/source/lib/util_unistr.c @@ -252,19 +252,27 @@ void unistr_to_ascii(char *dest, const uint16 *src, int len) { char *destend = dest + len; register uint16 c; - - while (dest < destend) - { - c = *(src++); - if (c == 0) - { - break; - } - - *(dest++) = (char)c; - } - - *dest = 0; + + /* deal with NULL src strings */ + if (src == NULL) + { + *dest = '\0'; + } + else + { + while (dest < destend) + { + c = *(src++); + if (c == 0) + { + break; + } + + *(dest++) = (char)c; + } + + *dest = 0; + } } /******************************************************************* |