Merge pull request #5752 from APriestman/6208_cookieNPE

6208 Fix NPE when cookie file page size is zero
This commit is contained in:
Richard Cordovano 2020-03-31 11:20:09 -04:00 committed by GitHub
commit 3f51a4c68b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,7 +89,7 @@ final class BinaryCookieReader implements Iterable<Cookie> {
throw new IOException(cookieFile.getName() + " is not a cookie file"); //NON-NLS throw new IOException(cookieFile.getName() + " is not a cookie file"); //NON-NLS
} }
int[] sizeArray = null; int[] sizeArray;
int pageCount = dataStream.readInt(); int pageCount = dataStream.readInt();
if (pageCount != 0) { if (pageCount != 0) {
sizeArray = new int[pageCount]; sizeArray = new int[pageCount];
@ -97,8 +97,9 @@ final class BinaryCookieReader implements Iterable<Cookie> {
for (int cnt = 0; cnt < pageCount; cnt++) { for (int cnt = 0; cnt < pageCount; cnt++) {
sizeArray[cnt] = dataStream.readInt(); sizeArray[cnt] = dataStream.readInt();
} }
} else {
LOG.log(Level.INFO, "No cookies found in {0}", cookieFile.getName()); //NON-NLS LOG.log(Level.INFO, "No cookies found in {0}", cookieFile.getName()); //NON-NLS
sizeArray = new int[0];
} }
reader = new BinaryCookieReader(cookieFile, sizeArray); reader = new BinaryCookieReader(cookieFile, sizeArray);