[PATCH GnuPG 5/7] g10: check null in assert
Jacob Bachmeyer
jcb62281 at gmail.com
Thu Jan 29 05:42:50 CET 2026
On 1/28/26 22:11, Sam James wrote:
> Jacob Bachmeyer<jcb62281 at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20260128/cbf30cff/attachment.html>
More information about the Gnupg-devel
mailing list