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 | f488740112449ca49d75d411a920edc6a605ff02 (patch) | |
tree | c7d206e491dd5102458a3d1af87191c466e41ca1 /source3/lib | |
parent | 0a86b83a86acbc048345bf0ddf6d0196ddc5b042 (diff) | |
download | samba-f488740112449ca49d75d411a920edc6a605ff02.tar.gz samba-f488740112449ca49d75d411a920edc6a605ff02.tar.bz2 samba-f488740112449ca49d75d411a920edc6a605ff02.zip |
Deal will NULL UNISTR in unistr_to_ascii
jerry
(This used to be commit cfa4c878a2ccaf346940f8f4a201737e185f76d6)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_unistr.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 42f1dc0644..0817dcf072 100644 --- a/source3/lib/util_unistr.c +++ b/source3/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; + } } /******************************************************************* |