Menu

#1 fix NPE in ImageInputStreamDecoder

open
nobody
None
5
2008-06-25
2008-06-25
Anonymous
No

public byte[] readBytes(final long pBytes, final byte[] pBuffer)
throws IOException {
byte[] lBuffer = pBuffer;
if (lBuffer == null) {
lBuffer = new byte[(int) pBytes];
} else {
if (lBuffer.length < pBytes) {
throw new IllegalArgumentException(
"Insufficient space in buffer");
}
}

*********
OLD: final int lBytesRead = _stream.read(pBuffer, 0, (int) pBytes);

FIX: final int lBytesRead = _stream.read(lBuffer, 0, (int) pBytes);

pBuffer is null when invoked i.e. by BitmapIndexed8BPP and lBuffer was allocated above

*********

if (lBytesRead != pBytes) {
throw new IOException("Tried to read " + pBytes
+ " bytes, but obtained " + lBytesRead);
}

_pos += pBytes;

return lBuffer;
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.