Bug 52662 - An incomplete fix for the NPE bug in CharacterRun.java
Summary: An incomplete fix for the NPE bug in CharacterRun.java
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-14 09:53 UTC by lianggt08
Modified: 2012-02-14 12:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.