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() {
|
public StructReader getStruct() {
|
||||||
return WireHelpers.readStructPointer(this.segment,
|
if (this.segment == null) {
|
||||||
this.pointer,
|
return WireHelpers.readStructPointer(SegmentReader.EMPTY, 0, this.nestingLimit);
|
||||||
this.nestingLimit);
|
} else {
|
||||||
|
return WireHelpers.readStructPointer(this.segment,
|
||||||
|
this.pointer,
|
||||||
|
this.nestingLimit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListReader getList(byte expectedElementSize) {
|
public ListReader getList(byte expectedElementSize) {
|
||||||
// TODO check nullness
|
if (this.segment == null) {
|
||||||
return WireHelpers.readListPointer(this.segment,
|
return WireHelpers.readListPointer(SegmentReader.EMPTY,
|
||||||
this.pointer,
|
0,
|
||||||
expectedElementSize,
|
expectedElementSize,
|
||||||
this.nestingLimit);
|
this.nestingLimit);
|
||||||
|
} else {
|
||||||
|
return WireHelpers.readListPointer(this.segment,
|
||||||
|
this.pointer,
|
||||||
|
expectedElementSize,
|
||||||
|
this.nestingLimit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Text.Reader getText() {
|
public Text.Reader getText() {
|
||||||
|
|
|
@ -13,4 +13,6 @@ public class SegmentReader {
|
||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
this.arena = arena;
|
this.arena = arena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final SegmentReader EMPTY = new SegmentReader(ByteBuffer.allocate(8), null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue