Fix NPE when page size is zero

This commit is contained in:
apriestman 2020-03-30 10:20:18 -04:00
parent 510b235c2d
commit f57b938a29

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);