Closed arthurscchan closed 9 months ago
I'm from the team that maintains https://github.com/amazon-ion/ion-java. IonReader.getIntegerSize()
should never throw NullPointerException
. I've opened https://github.com/amazon-ion/ion-java/issues/685 to get that fixed.
It will return null
when the reader is not positioned on an integer value, so that needs to be handled as described above.
In the
IonParser::getNumberType() method
, there is an invocation of theIonReader.getIntegerSize()
method which could return anull
value in some cases with invalid data. If the result is null, the code will throw a NullPointerException in the next line when the value is used for the switch condition.Also,
IonReader.getIntegerSize()
method will throwNullPointerException
in some cases, thus it is also necessary to wrap around the method invocation to ensureNullPointerException
is caught.The suggested fix is to add a null checking after the invocation of the
IonReader.getIntegerSize()
method and throw an exception if the return value stored insize
is indeed null. Also, wrap theIonReader.getIntegerSize()
method invocation with a try catch block to catch the possibleNullPointerException
.We found this issue by OSS-Fuzz and it is reported in https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65268 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65274.