From: Volker Lendecke Date: Wed, 2 Aug 2017 15:32:50 +0000 (+0200) Subject: lib: Only call strlen if necessary in strv X-Git-Tag: talloc-2.1.11~327 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e824ad69700412cedeb758029fdad4d1b5c6bbe;p=thirdparty%2Fsamba.git lib: Only call strlen if necessary in strv Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/lib/util/strv.c b/lib/util/strv.c index 864a3e5cf8b..328f561722b 100644 --- a/lib/util/strv.c +++ b/lib/util/strv.c @@ -79,7 +79,9 @@ static bool strv_valid_entry(const char *strv, size_t strv_len, return false; } - *entry_len = strlen(entry); + if (entry_len != NULL) { + *entry_len = strlen(entry); + } return true; } @@ -91,7 +93,7 @@ char *strv_next(char *strv, const char *entry) char *result; if (entry == NULL) { - if (strv_valid_entry(strv, len, strv, &entry_len)) { + if (strv_valid_entry(strv, len, strv, NULL)) { return strv; } return NULL;