findbugs: DocumentInputStream.skip(long) result not checked; close DocumentInputStream even if exception is thrown

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751020 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-07-02 04:39:53 +00:00
parent 6645d8a80f
commit d7900beec3

View File

@ -198,6 +198,7 @@ public class VBAMacroReader implements Closeable {
String name = entry.getName();
DocumentNode document = (DocumentNode)entry;
DocumentInputStream dis = new DocumentInputStream(document);
try {
if ("dir".equalsIgnoreCase(name)) {
// process DIR
RLEDecompressingInputStream in = new RLEDecompressingInputStream(dis);
@ -255,7 +256,10 @@ public class VBAMacroReader implements Closeable {
in = dis;
} else {
// we know the offset already, so decompress immediately on-the-fly
dis.skip(module.offset);
long skippedBytes = dis.skip(module.offset);
if (skippedBytes != module.offset) {
throw new IOException("tried to skip " + module.offset + " bytes, but actually skipped " + skippedBytes + " bytes");
}
in = new RLEDecompressingInputStream(dis);
}
final ByteArrayOutputStream out = new ByteArrayOutputStream();
@ -265,5 +269,9 @@ public class VBAMacroReader implements Closeable {
module.buf = out.toByteArray();
}
}
finally {
dis.close();
}
}
}
}