Details about the known misuse from the MUBench dataset.
| Description: | On line 365 _code.charAt() is invoked without ensuring that the respective
string actually has sufficiently many characters. From the constant
initialization on line 363 we take that k will assume the values 0 and 1,
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: | getBarsSupplemental2(String) |
| Code with Misuse: |
class BarcodeEAN {
/** Creates the bars for the barcode supplemental 2.
* @param _code the text with 2 digits
* @return the barcode
*/
public static byte[] getBarsSupplemental2(String _code) {
int code[] = new int[2];
for (int k = 0; k < code.length; ++k)
code[k] = _code.charAt(k) - '0';
byte bars[] = new byte[TOTALBARS_SUPP2];
int pb = 0;
int parity = (code[0] * 10 + code[1]) % 4;
bars[pb++] = 1;
bars[pb++] = 1;
bars[pb++] = 2;
byte sequence[] = PARITY2[parity];
for (int k = 0; k < sequence.length; ++k) {
if (k == 1) {
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;
}
}
|
| Code with Pattern(s): |
|