https://issues.apache.org/bugzilla/show_bug.cgi?id=52661
Bug #: 52661
Summary: An incomplete fix for the NPE bug in
HyperlinkRecord.java
Product: POI
Version: unspecified
Platform: PC
Status: NEW
Severity: critical
Priority: P2
Component: HSSF
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
The fix revision 720997 was aimed to remove an NPE bug on the "this._moniker"
in the method "toString" of the file
"/poi/trunk/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java" , but it
is incomplete.
Since the "this._moniker" is a class field and also could be null during the
run-time execution, it 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 559 of the method "serialize".
public void serialize(LittleEndianOutput out) {
_range.serialize(out);
_guid.serialize(out);
out.writeInt(0x00000002); // TODO const
out.writeInt(_linkOpts);
if ((_linkOpts & HLINK_LABEL) != 0){
out.writeInt(_label.length());
StringUtil.putUnicodeLE(_label, out);
}
if ((_linkOpts & HLINK_TARGET_FRAME) != 0){
out.writeInt(_targetFrame.length());
StringUtil.putUnicodeLE(_targetFrame, out);
}
if ((_linkOpts & HLINK_UNC_PATH) != 0) {
out.writeInt(_address.length());
StringUtil.putUnicodeLE(_address, out);
} else if ((_linkOpts & HLINK_URL) != 0){
[Line 559] _moniker.serialize(out);
if(URL_MONIKER.equals(_moniker)){
if ((_linkOpts & HLINK_TARGET_FRAME) != 0) {
out.writeInt(_address.length()*2);
StringUtil.putUnicodeLE(_address, out);
} else {
out.writeInt(_address.length()*2 + TAIL_SIZE);
StringUtil.putUnicodeLE(_address, out);
writeTail(_uninterpretedTail, out);
}
} else if (FILE_MONIKER.equals(_moniker)){
out.writeShort(_fileOpts);
out.writeInt(_shortFilename.length());
StringUtil.putCompressedUnicode(_shortFilename, out);
writeTail(_uninterpretedTail, out);
if (_address == null) {
out.writeInt(0);
} else {
int addrLen = _address.length() * 2;
out.writeInt(addrLen + 6);
out.writeInt(addrLen);
out.writeShort(0x0003); // TODO const
StringUtil.putUnicodeLE(_address, out);
}
}
}
if((_linkOpts & HLINK_PLACE) != 0){
out.writeInt(_textMark.length());
StringUtil.putUnicodeLE(_textMark, out);
}
}
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]