From: Joseph Sutton Date: Thu, 16 Nov 2023 23:52:29 +0000 (+1300) Subject: util/charset: Have talloc_utf16_str[n]dup() accept NULL pointers X-Git-Tag: talloc-2.4.2~618 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4629fc7c610a255fda33ae4dce0fd225b01e5c88;p=thirdparty%2Fsamba.git util/charset: Have talloc_utf16_str[n]dup() accept NULL pointers This is in line with ‘talloc_str[n]dup()’. Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index 54b7b939b1b..fa1a100e596 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -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)); }