* 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 <[email protected]>
---
 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


_______________________________________________
Gnupg-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gnupg-devel

Reply via email to