Skip to content

Commit a7a52f2

Browse files
committed
bsdauth_init/bsdauth_cleanup: auth_close() may not be passed NULL
While login_close() accepts a NULL pointer, auth_close() does not.
1 parent 38d909a commit a7a52f2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

plugins/sudoers/auth/bsdauth.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ bsdauth_init(const struct sudoers_context *ctx, struct passwd *pw,
9696
auth->data = (void *) &state;
9797
debug_return_int(AUTH_SUCCESS);
9898
bad:
99-
auth_close(state.as);
99+
if (state.as != NULL)
100+
auth_close(state.as);
100101
login_close(state.lc);
101102
debug_return_int(AUTH_ERROR);
102103
}
@@ -199,8 +200,10 @@ bsdauth_cleanup(const struct sudoers_context *ctx, struct passwd *pw,
199200
debug_decl(bsdauth_cleanup, SUDOERS_DEBUG_AUTH);
200201

201202
if (state != NULL) {
202-
auth_close(state->as);
203-
state->as = NULL;
203+
if (state->as != NULL) {
204+
auth_close(state->as);
205+
state->as = NULL;
206+
}
204207
login_close(state->lc);
205208
state->lc = NULL;
206209
auth->data = NULL;

0 commit comments

Comments
 (0)