Added pointer index check to StructReader._pointerFieldIsNull and StructBuilder._pointerFieldIsNull

This fixes an IndexOutOfBoundsException when checking for existence of later added fields which are only known on the receiver side (working with different schema versions)
This commit is contained in:
Amer Banet 2017-12-13 20:57:59 +01:00
parent 633b1f6199
commit 906bab78f9
2 changed files with 2 additions and 2 deletions

View file

@ -167,7 +167,7 @@ public class StructBuilder {
}
protected final boolean _pointerFieldIsNull(int ptrIndex) {
return this.segment.buffer.getLong((this.pointers + ptrIndex) * Constants.BYTES_PER_WORD) == 0;
return ptrIndex >= this.pointerCount || this.segment.buffer.getLong((this.pointers + ptrIndex) * Constants.BYTES_PER_WORD) == 0;
}
protected final void _clearPointerField(int ptrIndex) {

View file

@ -151,7 +151,7 @@ public class StructReader {
}
protected final boolean _pointerFieldIsNull(int ptrIndex) {
return this.segment.buffer.getLong((this.pointers + ptrIndex) * Constants.BYTES_PER_WORD) == 0;
return ptrIndex >= this.pointerCount || this.segment.buffer.getLong((this.pointers + ptrIndex) * Constants.BYTES_PER_WORD) == 0;
}
protected final <T> T _getPointerField(FromPointerReader<T> factory, int ptrIndex) {