Skip to content

Commit

Permalink
Fix reading larger ZIP files
Browse files Browse the repository at this point in the history
  • Loading branch information
dapetcu21 committed Feb 20, 2020
1 parent efccf84 commit 5925cae
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apkx/src/java/me/petcu/defoldapkx/DefoldInterface.java
Expand Up @@ -196,9 +196,13 @@ public static final byte[] zipGetFile(ZipResourceFile zip, String path) throws I
int uncompressedLength = (int)zip.getUncompressedLength(path);
byte[] bytes = new byte[uncompressedLength];

long readBytes = stream.read(bytes, 0, uncompressedLength);
if (readBytes < uncompressedLength) {
return null;
int index = 0;
while (index < uncompressedLength) {
int readBytes = stream.read(bytes, index, uncompressedLength - index);
if (readBytes < 0) {
return null; // Unexpected EOF
}
index += readBytes;
}

return bytes;
Expand Down

0 comments on commit 5925cae

Please sign in to comment.