MemoryDataStore: Handle weird arguments values correctly

Namely:
- Negative arguments to InputStream::skip(n).
- Large arguments to readAt(offset).
This commit is contained in:
Lanchon 2017-09-24 21:59:36 -03:00 committed by Ben Gruver
parent c645b9d546
commit b9a725e726

View File

@ -105,13 +105,13 @@ public class MemoryDataStore implements DexDataStore {
}
@Override public long skip(long n) throws IOException {
int skipLength = (int)Math.min(n, size - position);
int skipLength = (int)Math.max(0, Math.min(n, size - position));
position += skipLength;
return skipLength;
}
@Override public int available() throws IOException {
return size - position;
return Math.max(0, size - position);
}
};
}