From e5a8a6f9720ec9f2990de55df35ee5f16cff8714 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Mon, 2 Jan 2023 20:30:16 -0600 Subject: [PATCH] krb5: Quiet static analyzer warning in krbhst --- lib/krb5/krbhst.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/krb5/krbhst.c b/lib/krb5/krbhst.c index 8fb87f8e1..f1019e2a9 100644 --- a/lib/krb5/krbhst.c +++ b/lib/krb5/krbhst.c @@ -343,7 +343,13 @@ append_host_hostinfo(struct krb5_krbhst_data *kd, struct krb5_krbhst_info *host) _krb5_free_krbhst_info(host); return; } - *kd->end = host; + /* + * We should always initialize kd->end in common_init(), but static + * analyzers may not see that we do, and the compiler might conclude + * there's UB here. + */ + if (kd->end) + *kd->end = host; kd->end = &host->next; }