Details about the known misuse from the MUBench dataset.
Description:
The method PdfLayer.getAsString() is invoked and the result is immediately converted toUnicodeString(), without checking whether it is null. From the documentation og getAsString() we take that this is unsafe:
"Returns a PdfObject as a PdfString, resolving indirect references. The object associated with the PdfName given is retrieved and resolved to a direct object. If it is a PdfString, it is cast down and returned as such. Otherwise null is returned."
Fix Description:
Violation Types:
missing/condition/value_or_state
In File:
com/itextpdf/text/pdf/PdfLayer.java
In Method:
addChild(PdfLayer)
Code with Misuse:
class PdfLayer {
/**
* Adds a child layer. Nested layers can only have one parent.
* @param child the child layer
*/
public void addChild(PdfLayer child) {
if (child.parent != null)
throw new IllegalArgumentException(MessageLocalization.getComposedMessage("the.layer.1.already.has.a.parent", child.getAsString(PdfName.NAME).toUnicodeString()));
child.parent = this;
if (children == null)
children = new ArrayList<PdfLayer>();
children.add(child);
}
}