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

Jacob Bachmeyer via Gnupg-devel <[email protected]> Wed, 28 Jan 2026 22:42:50 -0600
Newsgroups gmane.comp.encryption.gpg.devel
Message-ID <[email protected]>
On 1/28/26 22:11, Sam James wrote:
> Jacob Bachmeyer<[email protected]> writes:
> [...]
>> Alternately, is it possible for this code to be reached if keyblock is
>> NULL?  Perhaps a better solution would be to change the "if (err)" to
>> "if (err || !keyblock)" or the more verbose "if (err != 0 || keyblock
>> == NULL)"?  (I assume that quick_find_keyblock always returns an error
>> if keyblock is NULL upon return, but the analyzer does not know that.)
> Yes, this is a pattern I saw a few times where it doesn't understand
> error-return relations, unfortunately.
>
> It does look into q_f_k, it just isn't able to deduce that they're tied,
> even though when looking at it, it seems to be fine.
>
> [...]
> I plan on filing some GCC bugs for any analyzer shortcomings we end up
> finding so the discussion is interesting, thanks.

I think that the analyzer being unable to recognize that "!err" implies 
keyblock is non-NULL even though it *does* look inside the 
quick_find_keyblock function is a shortcoming worth a GCC bug report 
because it results in complaints for which maintainers could 
legitimately reject patches, as there is no actual problem.


-- Jacob

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