From f488740112449ca49d75d411a920edc6a605ff02 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 10 Aug 2000 14:00:05 +0000 Subject: Deal will NULL UNISTR in unistr_to_ascii jerry (This used to be commit cfa4c878a2ccaf346940f8f4a201737e185f76d6) --- source3/lib/util_unistr.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'source3/lib') 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; + } } /******************************************************************* -- cgit