Bug 52662

Summary: An incomplete fix for the NPE bug in CharacterRun.java
Product: POI Reporter: lianggt08
Component: HWPFAssignee: POI Developers List <dev>
Severity: critical    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description lianggt08 2012-02-14 09:53:17 UTC
The fix revision 1142762 was aimed to remove an NPE bug on the returned value of  "_doc.getFontTable() " in the method "toString" of the file "/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java" , but it is incomplete. 
Since the "_doc.getFontTable()" could be null during the run-time execution, its returned value should also be null-checked before being dereferenced in other methods. 

The buggy code locations the same fix needs to be applied at are as bellows: 
Line 609 of the method "getSymbolFont". 

public Ffn getSymbolFont()
    if (isSymbol()) {
[Line 609]      Ffn[] fontNames = _doc.getFontTable().getFontNames();

      if (fontNames.length <= _props.getFtcSym())
        return null;

      return fontNames[_props.getFtcSym()];
    } else
      throw new IllegalStateException("Not a symbol CharacterRun");
Comment 1 Nick Burch 2012-02-14 12:56:40 UTC
Thanks, applied in r1243907.