...
This noncompliant example shows a bug in Tomcat version 4.1.24, initially discovered by Reasoning [Reasoning 2003]. The cardinality()
method was designed to return the number of occurrences of object obj
in collection col
. One valid use of the cardinality()
method is to determine how many objects in the collection are null
. However, because membership in the collection is checked using the expression obj.equals(elt)
, a null pointer dereference is guaranteed whenever obj
is null
and elt
is not null
.
...