From: Todd C. Miller Date: Wed, 28 Feb 2018 21:44:54 +0000 (-0700) Subject: Quiet a clang analyzer warning. X-Git-Tag: SUDO_1_8_23^2~107 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8da213c8be74e23e9e6c008c2ff27e0a0c653668;p=sudo Quiet a clang analyzer warning. --- diff --git a/plugins/sudoers/cvtsudoers_ldif.c b/plugins/sudoers/cvtsudoers_ldif.c index f4a4b67d9..6b85bbea9 100644 --- a/plugins/sudoers/cvtsudoers_ldif.c +++ b/plugins/sudoers/cvtsudoers_ldif.c @@ -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; }