Details about the known misuse from the MUBench dataset.
Description:
On line 403 _code.charAt() is invoked without ensuring that the respective
string actually has sufficiently many characters. From the constant
initialization on line 401 we take that k will assume the values from
[0, 4], while _code might be any string.
Fix Description:
Violation Types:
missing/condition/value_or_state
In File:
com/itextpdf/text/pdf/BarcodeEAN.java
In Method:
getBarsSupplemental5(String)
Code with Misuse:
class BarcodeEAN {
/** Creates the bars for the barcode supplemental 5.
* @param _code the text with 5 digits
* @return the barcode
*/
public static byte[] getBarsSupplemental5(String _code) {
int code[] = new int[5];
for (int k = 0; k < code.length; ++k)
code[k] = _code.charAt(k) - '0';
byte bars[] = new byte[TOTALBARS_SUPP5];
int pb = 0;
int parity = (((code[0] + code[2] + code[4]) * 3) + ((code[1] + code[3]) * 9)) % 10;
bars[pb++] = 1;
bars[pb++] = 1;
bars[pb++] = 2;
byte sequence[] = PARITY5[parity];
for (int k = 0; k < sequence.length; ++k) {
if (k != 0) {
bars[pb++] = 1;
bars[pb++] = 1;
}
int c = code[k];
byte stripes[] = BARS[c];
if (sequence[k] == ODD) {
bars[pb++] = stripes[0];
bars[pb++] = stripes[1];
bars[pb++] = stripes[2];
bars[pb++] = stripes[3];
}
else {
bars[pb++] = stripes[3];
bars[pb++] = stripes[2];
bars[pb++] = stripes[1];
bars[pb++] = stripes[0];
}
}
return bars;
}
}