summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/util_unistr.c34
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;
+ }
}
/*******************************************************************