Bug 63151 - NPE in UnicodeString.swapFontUse on invoking HSSFOptimiser.optimiseFonts
Summary: NPE in UnicodeString.swapFontUse on invoking HSSFOptimiser.optimiseFonts
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 4.0.0-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-07 09:29 UTC by Anthony V
Modified: 2019-02-19 06:28 UTC (History)
0 users



Attachments
A test case to reproduce the issue (821 bytes, text/plain)
2019-02-07 09:29 UTC, Anthony V
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony V 2019-02-07 09:29:57 UTC
Created attachment 36428 [details]
A test case to reproduce the issue

Please find a reproducer in attachment.
This is with Java 11 and POI 4.0.1.

The stack trace is:
Exception in thread "main" java.lang.NullPointerException
	at org.apache.poi.hssf.record.common.UnicodeString.swapFontUse(UnicodeString.java:676)
	at org.apache.poi.hssf.usermodel.HSSFOptimiser.optimiseFonts(HSSFOptimiser.java:155)
	at ...


The problem is fairly obvious: the line loops over the elements of field_4_format_runs without doing a null-check on it first.
Comment 1 PJ Fanning 2019-02-19 06:28:00 UTC
fix applied in https://svn.apache.org/viewvc?view=revision&revision=1853859