Eric Blake <ebl...@redhat.com> writes:

> It silences static code checkers and avoids undefined C behavior.
>
> Also, if invokers[] is allocated such that it ends on the end of a page
> boundary (such as might be the case under certain malloc debuggers),
> then doing the bounds check first will avoid an out-of-bounds access
> causing a SEGFAULT.

invokers[] is guaranteed to end with a NULL element, so there cannot be
any out-of-bounds access, and the use is completely defined.  The NULL
check is the primary condition, with the index check only being
secondary.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

Reply via email to