Bug 56911

Summary: PlfLfo.add(LFO, LFOData) results in IOOBE
Product: POI Reporter: Yaniv Kunda <yaniv>
Component: HWPFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.11-dev   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Yaniv Kunda 2014-09-04 09:23:10 UTC
The following code in the method will always result in a IOOBE:

_rgLfo[_lfoMac + 1] = lfo;
_rgLfoData[_lfoMac + 1] = lfoData;

should be:

_rgLfo[_lfoMac] = lfo;
_rgLfoData[_lfoMac] = lfoData;

Sadly, this code is only reachable from the external org.apache.poi.hwpf.HWPFDocument#registerList(HWPFList) method, and has no tests.
Furthermore, org.apache.poi.hwpf.model.TestListTables has a single test which does nothing - it uses a fixture that causes the first "if" to essentially skip the test.

I am not familiar with this object model, so I cannot provide a sensible test.
Comment 1 Dominik Stadler 2016-04-05 15:30:58 UTC
I cannot see the problem with the code, it first enlarges the array and then puts the element into the postion that was just newly created, so should not cause any Exception.

Please reopen if you can provide a unit-test that shows how it causes an Exception here.
Comment 2 Dominik Stadler 2016-04-05 15:32:34 UTC
Oops, sorry, I was wrong, seems to be really broken, but not used anywhere at all.
Comment 3 Dominik Stadler 2016-04-06 09:02:49 UTC
Fixed via r1737947 for 3.15-beta2, seems only very few people use this as it can never have worked before.