summaryrefslogtreecommitdiff
path: root/source3/lib/util_unistr.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_unistr.c')
-rw-r--r--source3/lib/util_unistr.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index 9078a4fbc6..6f90528bf4 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -267,13 +267,23 @@ copies a UNISTR2 structure.
********************************************************************/
BOOL copy_unistr2(UNISTR2 *str, const UNISTR2 *from)
{
- /* set up string lengths. add one if string is not null-terminated */
- str->uni_max_len = from->uni_max_len;
- str->undoc = from->undoc;
- str->uni_str_len = from->uni_str_len;
+ if (from != NULL)
+ {
+ /* set up string lengths. add one if string is not null-terminated */
+ str->uni_max_len = from->uni_max_len;
+ str->undoc = from->undoc;
+ str->uni_str_len = from->uni_str_len;
- /* copy the string */
- memcpy(str->buffer, from->buffer, sizeof(from->buffer));
+ /* copy the string */
+ memcpy(str->buffer, from->buffer, sizeof(from->buffer));
+ }
+ else
+ {
+ str->uni_max_len = 1;
+ str->undoc = 0;
+ str->uni_str_len = 1;
+ str->buffer[0] = 0;
+ }
return True;
}