Skip to content

Commit

Permalink
Ensures NullPointerException is not thrown from IonReader.getIntegerS…
Browse files Browse the repository at this point in the history
…ize().
  • Loading branch information
tgregg committed Jan 2, 2024
1 parent be0ed07 commit 1a09a29
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void prepareScalar() {

@Override
public IntegerSize getIntegerSize() {
if (valueTid.type != IonType.INT || valueTid.isNull) {
if (valueTid == null || valueTid.type != IonType.INT || valueTid.isNull) {
return null;
}
prepareScalar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ protected IonReaderTextSystemX(UnifiedInputStreamX iis)
// into a base class (the *Value() methods also share a lot of similarity).
public IntegerSize getIntegerSize()
{
load_once();
if (_value_type != IonType.INT || _v.isNull())
{
return null;
}
load_once();
return _Private_ScalarConversions.getIntegerSize(_v.getAuthoritativeType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void testGetIntegerSizeNull()
+ "[] "
+ "() "
);
assertNull(in.getIntegerSize());
while (in.next() != null)
{
assertNull(in.getIntegerSize());
Expand Down

0 comments on commit 1a09a29

Please sign in to comment.