cpu: In SimpleIndirectPredictor, avoid an accidental nullptr deref.
The default value of IPredEntry::tag is 0, and if we just blindly
compare the tag we're looking for against this value, we might run into
cases where we match against an uninitialized IPredEntry. In that case,
IPredEntry::target has not been initialized, and if we try to use it in
lookup(...) we'll dereference nullptr and segfault.
To avoid that, we can just add one additional check that makes sure that
not only does the tag of the IPredEntry match, but also that the value
of target is not null, and so the IPredEntry *actually* has tag 0 and
isn't just uninitialized.
Maintainer: Gabe Black <email@example.com>
Reviewed-by: Jason Lowe-Power <firstname.lastname@example.org>
Tested-by: kokoro <email@example.com>
1 file changed