]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/list.c: is_on_list(): Move break condition to loop controlling expression
authorAlejandro Colomar <alx@kernel.org>
Wed, 17 Jan 2024 01:50:42 +0000 (02:50 +0100)
committerSerge Hallyn <serge@hallyn.com>
Thu, 14 Mar 2024 22:11:36 +0000 (17:11 -0500)
This change executes `i++` one more time before breaking, so we need to
update the `i+1` after the loop to just `i`.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/list.c

index b88f5c5ab07937baccb7ddfe17473ed4e06c4121..28f530685cd62cf5d5b9d2174a6c348bf5d43ff5 100644 (file)
@@ -232,15 +232,13 @@ bool is_on_list (char *const *list, const char *member)
         * array of pointers.
         */
 
-       for (cp = members, i = 0;; i++) {
+       for (cp = members, i = 0; cp != NULL; i++) {
                array[i] = cp;
                cp = strchr(cp, ',');
                if (NULL != cp)
                        *cp++ = '\0';
-               else
-                       break;
        }
-       array[i+1] = NULL;
+       array[i] = NULL;
 
        /*
         * Return the new array of pointers