[PATCH GnuPG 3/7] common: fix -Werror=analyzer-deref-before-check
Sam James via Gnupg-devel <[email protected]> Wed, 28 Jan 2026 12:35:03 +0000
| Newsgroups | gmane.comp.encryption.gpg.devel |
|---|---|
| Message-ID | <46470da1242fd39478e8b9c0c17552fbf6baddeb.1769603707.git.sam@gentoo.org> |
* 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