Bug 63151

Summary: NPE in UnicodeString.swapFontUse on invoking HSSFOptimiser.optimiseFonts
Product: POI Reporter: Anthony V <anthonyv.be>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 4.0.0-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: A test case to reproduce the issue

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