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=62208

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912251 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-09-11 18:25:06 +00:00
parent dbd8808432
commit e666d3756e
3 changed files with 4 additions and 2 deletions

View File

@ -259,7 +259,7 @@ public class ReadOnlySharedStringsTable extends DefaultHandler implements Shared
} else if ("rPh".equals(localName)) { } else if ("rPh".equals(localName)) {
inRPh = true; inRPh = true;
//append space...this assumes that rPh always comes after regular <t> //append space...this assumes that rPh always comes after regular <t>
if (includePhoneticRuns && characters.length() > 0) { if (includePhoneticRuns && characters != null && characters.length() > 0) {
characters.append(" "); characters.append(" ");
} }
} }
@ -287,7 +287,9 @@ public class ReadOnlySharedStringsTable extends DefaultHandler implements Shared
public void characters(char[] ch, int start, int length) throws SAXException { public void characters(char[] ch, int start, int length) throws SAXException {
if (tIsOpen) { if (tIsOpen) {
if (inRPh && includePhoneticRuns) { if (inRPh && includePhoneticRuns) {
characters.append(ch, start, length); if (characters != null) {
characters.append(ch, start, length);
}
} else if (! inRPh){ } else if (! inRPh){
if (characters != null) { if (characters != null) {
characters.append(ch, start, length); characters.append(ch, start, length);

Binary file not shown.