MemoryDataStore: Fail fast on invalid offsets

This commit is contained in:
Lanchon 2017-09-24 22:07:00 -03:00 committed by Ben Gruver
parent c41c24a0c2
commit f1c116241a

View File

@ -31,6 +31,7 @@ public class MemoryDataStore implements DexDataStore {
} }
@Nonnull @Override public OutputStream outputAt(final int offset) { @Nonnull @Override public OutputStream outputAt(final int offset) {
if (offset < 0) throw new IllegalArgumentException();
return new OutputStream() { return new OutputStream() {
private int position = offset; private int position = offset;
@Override public void write(int b) throws IOException { @Override public void write(int b) throws IOException {
@ -68,6 +69,7 @@ public class MemoryDataStore implements DexDataStore {
} }
@Nonnull @Override public InputStream readAt(final int offset) { @Nonnull @Override public InputStream readAt(final int offset) {
if (offset < 0) throw new IllegalArgumentException();
return new InputStream() { return new InputStream() {
private int position = offset; private int position = offset;
private int mark = offset; private int mark = offset;