Bug 66425: Avoid a NullPointerException found via oss-fuzz

We try to avoid throwing NullPointerException, but it was possible
to trigger one here with a specially crafted input-file

Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62074

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912125 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-09-06 09:48:21 +00:00
parent 35901849f1
commit 4b03c24ec8
4 changed files with 5 additions and 1 deletions

View File

@ -380,6 +380,10 @@ public class XSSFReader {
*/
@Override
public InputStream next() {
if (!sheetIterator.hasNext()) {
throw new IllegalStateException("Cannot get next from iterator");
}
xssfSheetRef = sheetIterator.next();
String sheetId = xssfSheetRef.getId();

View File

@ -831,7 +831,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
private XSSFName createAndStoreName(CTDefinedName ctName) {
XSSFName name = new XSSFName(ctName, this);
namedRanges.add(name);
namedRangesByName.put(ctName.getName().toLowerCase(Locale.ENGLISH), name);
namedRangesByName.put(ctName.getName() == null ? null : ctName.getName().toLowerCase(Locale.ENGLISH), name);
return name;
}

Binary file not shown.