]> granicus.if.org Git - sudo/commitdiff
Quiet a clang analyzer warning.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Wed, 28 Feb 2018 21:44:54 +0000 (14:44 -0700)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Wed, 28 Feb 2018 21:44:54 +0000 (14:44 -0700)
plugins/sudoers/cvtsudoers_ldif.c

index f4a4b67d98c0147d5bcd6d302ef88d3481a2c179..6b85bbea931b6cb6771c15f4a1cff935f252db73 100644 (file)
@@ -871,8 +871,10 @@ parse_ldif(const char *input_file, struct cvtsudoers_config *conf)
                role = NULL;
                in_role = false;
            }
-           if (len == -1)
+           if (len == -1) {
+               free(role);
                break;
+           }
            mismatch = false;
            continue;
        }
@@ -1002,7 +1004,9 @@ parse_ldif(const char *input_file, struct cvtsudoers_config *conf)
 
     /* Convert from list of roles to array and sort by order. */
     role_array = reallocarray(NULL, numroles + 1, sizeof(*role_array));
-    for (n = 0; (role = STAILQ_FIRST(&roles)) != NULL; n++) {
+    for (n = 0; n < numroles; n++) {
+       if ((role = STAILQ_FIRST(&roles)) == NULL)
+           break;      /* cannot happen */
        STAILQ_REMOVE_HEAD(&roles, entries);
        role_array[n] = role;
     }