mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-20 03:24:55 +00:00
Fixing NPEs
This commit is contained in:
parent
8e01b23e3c
commit
4450c2694f
@ -1161,28 +1161,33 @@ class SevenZipExtractor {
|
|||||||
tokens.add(toks[i]);
|
tokens.add(toks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<byte[]> byteTokens = new ArrayList<>(tokens.size());
|
List<byte[]> byteTokens = null;
|
||||||
int last = 0;
|
if (filePathBytes == null) {
|
||||||
for (int i = 0; i < filePathBytes.length; i++) {
|
return addNode(rootNode, tokens, null);
|
||||||
if (filePathBytes[i] == '/') {
|
} else {
|
||||||
int len = i - last;
|
byteTokens = new ArrayList<>(tokens.size());
|
||||||
|
int last = 0;
|
||||||
|
for (int i = 0; i < filePathBytes.length; i++) {
|
||||||
|
if (filePathBytes[i] == '/') {
|
||||||
|
int len = i - last;
|
||||||
|
byte[] arr = new byte[len];
|
||||||
|
System.arraycopy(filePathBytes, last, arr, 0, len);
|
||||||
|
byteTokens.add(arr);
|
||||||
|
last = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int len = filePathBytes.length - last;
|
||||||
|
if (len > 0) {
|
||||||
byte[] arr = new byte[len];
|
byte[] arr = new byte[len];
|
||||||
System.arraycopy(filePathBytes, last, arr, 0, len);
|
System.arraycopy(filePathBytes, last, arr, 0, len);
|
||||||
byteTokens.add(arr);
|
byteTokens.add(arr);
|
||||||
last = i + 1;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
int len = filePathBytes.length - last;
|
if (tokens.size() != byteTokens.size()) {
|
||||||
if (len > 0) {
|
logger.log(Level.WARNING, "Could not map path bytes to path string");
|
||||||
byte[] arr = new byte[len];
|
return addNode(rootNode, tokens, null);
|
||||||
System.arraycopy(filePathBytes, last, arr, 0, len);
|
}
|
||||||
byteTokens.add(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
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, byteTokens);
|
return addNode(rootNode, tokens, byteTokens);
|
||||||
@ -1205,12 +1210,17 @@ class SevenZipExtractor {
|
|||||||
|
|
||||||
// get the next name in the path and look it up
|
// get the next name in the path and look it up
|
||||||
String childName = tokenPath.remove(0);
|
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);
|
UnpackedNode child = parent.getChild(childName);
|
||||||
// create new node
|
// create new node
|
||||||
if (child == null) {
|
if (child == null) {
|
||||||
child = new UnpackedNode(childName, parent);
|
child = new UnpackedNode(childName, parent);
|
||||||
child.setFileNameBytes(childNameBytes);
|
if (childNameBytes != null) {
|
||||||
|
child.setFileNameBytes(childNameBytes);
|
||||||
|
}
|
||||||
parent.addChild(child);
|
parent.addChild(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user