add some null checks
This commit is contained in:
parent
e65b934db0
commit
3c6d02ecdd
2 changed files with 20 additions and 8 deletions
|
@ -29,17 +29,27 @@ public final class PointerReader {
|
|||
}
|
||||
|
||||
public StructReader getStruct() {
|
||||
return WireHelpers.readStructPointer(this.segment,
|
||||
this.pointer,
|
||||
this.nestingLimit);
|
||||
if (this.segment == null) {
|
||||
return WireHelpers.readStructPointer(SegmentReader.EMPTY, 0, this.nestingLimit);
|
||||
} else {
|
||||
return WireHelpers.readStructPointer(this.segment,
|
||||
this.pointer,
|
||||
this.nestingLimit);
|
||||
}
|
||||
}
|
||||
|
||||
public ListReader getList(byte expectedElementSize) {
|
||||
// TODO check nullness
|
||||
return WireHelpers.readListPointer(this.segment,
|
||||
this.pointer,
|
||||
expectedElementSize,
|
||||
this.nestingLimit);
|
||||
if (this.segment == null) {
|
||||
return WireHelpers.readListPointer(SegmentReader.EMPTY,
|
||||
0,
|
||||
expectedElementSize,
|
||||
this.nestingLimit);
|
||||
} else {
|
||||
return WireHelpers.readListPointer(this.segment,
|
||||
this.pointer,
|
||||
expectedElementSize,
|
||||
this.nestingLimit);
|
||||
}
|
||||
}
|
||||
|
||||
public Text.Reader getText() {
|
||||
|
|
|
@ -13,4 +13,6 @@ public class SegmentReader {
|
|||
this.buffer = buffer;
|
||||
this.arena = arena;
|
||||
}
|
||||
|
||||
public static final SegmentReader EMPTY = new SegmentReader(ByteBuffer.allocate(8), null);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue