lib: Only call strlen if necessary in strv
authorVolker Lendecke <vl@samba.org>
Wed, 2 Aug 2017 15:32:50 +0000 (17:32 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 29 Nov 2017 15:59:15 +0000 (16:59 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/util/strv.c

index 864a3e5cf8ba88636daedf6ddef55c0d102d902e..328f561722b8c10f1c0fee45c62f53e3bfb66d1f 100644 (file)
@@ -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;