From cf023a7ce0ba08f3b7e37fecf8219e83c04ed418 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 12 Aug 2000 14:20:40 +0000 Subject: fixed unistr_to_ascii to deal with NULL src strings jerry (This used to be commit 8e95aae1709a9be28d6e25ff6f0fdc729dc09274) --- source3/lib/util_unistr.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 0817dcf072..b786d0c98b 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -253,26 +253,26 @@ void unistr_to_ascii(char *dest, const uint16 *src, int len) char *destend = dest + len; register uint16 c; - /* deal with NULL src strings */ if (src == NULL) { *dest = '\0'; + return; } - else + + /* normal code path for a valid 'src' */ + while (dest < destend) { - while (dest < destend) - { - c = *(src++); - if (c == 0) - { - break; - } - - *(dest++) = (char)c; - } - - *dest = 0; + c = *(src++); + if (c == 0) + { + break; + } + + *(dest++) = (char)c; } + + *dest = 0; + return; } /******************************************************************* -- cgit