Language: Java
Label: vulnerable
CWE: CWE-502 \u2014 Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.

Code:
	public boolean[] readBooleanArray() throws IOException {
		final int bitCount = localBuffer.readInt();
		if (bitCount == -1) {
			return null;
		}

		byte[] data = readByteArray();
		if (bitCount == 0) {
			return new boolean[0];
		} else if (data == null) {
			throw new NullPointerException("Boolean's byte array is null");
		}

		BitSet bits = BitSet.valueOf(data);

		final boolean[] arr = new boolean[bitCount];
		IntStream.range(0, bitCount).forEach(i -> arr[i] = bits.get(i));
		return arr;
	}