[PATCH GnuPG 5/7] g10: check null in assert

Sam James via Gnupg-devel <[email protected]> Wed, 28 Jan 2026 12:35:05 +0000
Newsgroups gmane.comp.encryption.gpg.devel
Message-ID <15cec20c30ff79a9478e2960224848574dcbc977.1769603707.git.sam@gentoo.org>
* g10/keyedit.c (keyedit_quick_revsig): Check 'keyblock' in log_assert.

--

Found by GCC's -fanalyzer.

Signed-off-by: Sam James <[email protected]>
---
 g10/keyedit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/g10/keyedit.c b/g10/keyedit.c
index 970a72027..567de4efd 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -3306,8 +3306,8 @@ keyedit_quick_revsig (ctrl_t ctrl, const char *username, const char *sigtorev,
   err = quick_find_keyblock (ctrl, username, 0, &kdbhd, &keyblock);
   if (err)
     goto leave;
-  log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY
-              || keyblock->pkt->pkttype == PKT_SECRET_KEY);
+  log_assert (keyblock && (keyblock->pkt->pkttype == PKT_PUBLIC_KEY
+              || keyblock->pkt->pkttype == PKT_SECRET_KEY));
   primarypk = keyblock->pkt->pkt.public_key;
   primarykid = pk_keyid (primarypk);
 
-- 
2.52.0