[PATCH GnuPG 3/7] common: fix -Werror=analyzer-deref-before-check

Sam James sam at gentoo.org
Wed Jan 28 13:35:03 CET 2026


* common/iobuf.c (iobuf_get_real_fname): Check if 'a' is null earlier.

--

Check `a` before it is used in an if, because we later do a null-pointer
check in the loop which triggers a "null pointer check but too late"
warning.

The callers seem safe already but fix it to stop GCC's -fanalyzer
complaining.

Found by GCC's -fanalyzer.

Signed-off-by: Sam James <sam at gentoo.org>
---
 common/iobuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/iobuf.c b/common/iobuf.c
index 769df958d..09cedbb50 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -2768,7 +2768,7 @@ iobuf_seek (iobuf_t a, off_t newpos)
 const char *
 iobuf_get_real_fname (iobuf_t a)
 {
-  if (a->real_fname)
+  if (a && a->real_fname)
     return a->real_fname;
 
   /* the old solution */
-- 
2.52.0




More information about the Gnupg-devel mailing list