]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
util/charset: Have talloc_utf16_str[n]dup() accept NULL pointers
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 16 Nov 2023 23:52:29 +0000 (12:52 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 20 Nov 2023 21:50:32 +0000 (21:50 +0000)
This is in line with ‘talloc_str[n]dup()’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/charset/util_unistr.c

index 54b7b939b1bf36f339e43464dca715f83402eef0..fa1a100e596878416f5228c23cb5b12ab64f9f1d 100644 (file)
@@ -280,11 +280,17 @@ uint16_t *talloc_utf16_strlendup(TALLOC_CTX *mem_ctx, const char *str, size_t le
 
 uint16_t *talloc_utf16_strdup(TALLOC_CTX *mem_ctx, const char *str)
 {
+       if (str == NULL) {
+               return NULL;
+       }
        return talloc_utf16_strlendup(mem_ctx, str, utf16_len(str));
 }
 
 uint16_t *talloc_utf16_strndup(TALLOC_CTX *mem_ctx, const char *str, size_t n)
 {
+       if (str == NULL) {
+               return NULL;
+       }
        return talloc_utf16_strlendup(mem_ctx, str, utf16_len_n(str, n));
 }