Add rudimentary check for int overflow in size calculation
Can't do much with a size that overflowed max int.
@@ -529,6 +529,10 @@ public final class NestedSet<E> {
int size = 0;
for (int i = memo.length - 1; ; i--) {
size = (size << 7) | (memo[i] & 0x7f);
+ if (size < 0) {
+ throw new IllegalStateException(
+ "int overflow calculating size (" + size + "), memo: " + Arrays.toString(memo));
+ }
if ((memo[i] & 0x80) != 0) {
return size;
}
