Fixing NPEs

This commit is contained in:
Ethan Roseman 2019-09-11 15:08:55 -04:00
parent 8e01b23e3c
commit 4450c2694f

View File

@ -1162,7 +1162,11 @@ class SevenZipExtractor {
}
}
List<byte[]> byteTokens = new ArrayList<>(tokens.size());
List<byte[]> byteTokens = null;
if (filePathBytes == null) {
return addNode(rootNode, tokens, null);
} else {
byteTokens = new ArrayList<>(tokens.size());
int last = 0;
for (int i = 0; i < filePathBytes.length; i++) {
if (filePathBytes[i] == '/') {
@ -1182,7 +1186,8 @@ class SevenZipExtractor {
if (tokens.size() != byteTokens.size()) {
logger.log(Level.WARNING, "Could not map path bytes to path string");
return addNode(rootNode, tokens, new ArrayList<>());
return addNode(rootNode, tokens, null);
}
}
return addNode(rootNode, tokens, byteTokens);
@ -1205,12 +1210,17 @@ class SevenZipExtractor {
// get the next name in the path and look it up
String childName = tokenPath.remove(0);
byte[] childNameBytes = tokenPathBytes.remove(0);
byte[] childNameBytes = null;
if (tokenPathBytes != null) {
childNameBytes = tokenPathBytes.remove(0);
}
UnpackedNode child = parent.getChild(childName);
// create new node
if (child == null) {
child = new UnpackedNode(childName, parent);
if (childNameBytes != null) {
child.setFileNameBytes(childNameBytes);
}
parent.addChild(child);
}