a = new ArraySet();
b = new ArraySet();
b.addAll(a); // throw exception
a = new ArraySet(1);
a.add("x");
a.clear();
b = new ArraySet();
b.addAll(a); // throw exception or b = {"x"}
Additional context
The following logic is incorrect because the valid data for as needs to take into account the content of numElements. Thus, directly iterating through the entire elements will not only generate exceptions but also lead to incorrect additions.
for (E elem : as.elements) {
ret |= add(elem);
}
=>
for (int i = 0; i < as.numElements; i++) {
ret |= add(as.elements[i]);
}
Describe the bug The implementation of
addAll
in ArraySet has a logical issue that almost certainly triggers the oops exception in theadd
method.https://github.com/soot-oss/soot/blob/d4061dca597daa54b72ef093f027ceed5072178e/src/main/java/soot/util/ArraySet.java#L121
To reproduce
Additional context
The following logic is incorrect because the valid data for
as
needs to take into account the content ofnumElements
. Thus, directly iterating through the entireelements
will not only generate exceptions but also lead to incorrect additions.=>