Program: 58361
Project: 58361
Buggy source:
private boolean processPdf417(){
  int i, j, blockCount, loop, offset;
  int[] mccorrection=new int[520];
  int total;
  int c1, c2, c3;
  int[] dummy=new int[35];
  String codebarre;
  int length=inputData.length;
  EncodingMode currentEncodingMode;
  int selectedECCLevel;
  String bin;
  blockIndex=0;
  blockCount=0;
  currentEncodingMode=chooseMode(inputData[blockCount]);
  for (i=0; i < 1000; i++) {
    blockLength[i]=0;
  }
  do {
    blockType[blockIndex]=currentEncodingMode;
    while ((blockType[blockIndex] == currentEncodingMode) && (blockCount < length)) {
      blockLength[blockIndex]++;
      blockCount++;
      if (blockCount < length) {
        currentEncodingMode=chooseMode(inputData[blockCount]);
      }
    }
    blockIndex++;
  }
 while (blockCount < length);
  for (i=0; i < blockIndex; i++) {
    if ((blockType[i] == EncodingMode.NUM) && (blockLength[i] > 44)) {
      for (j=blockIndex + 1; j > (i + 1); j--) {
        blockType[j]=blockType[j - 1];
        blockLength[j]=blockLength[j - 1];
      }
      blockType[i + 1]=blockType[i];
      blockLength[i + 1]=blockLength[i] - 44;
      blockLength[i]=44;
      blockIndex++;
    }
  }
  pdfSmooth();
  blockCount=0;
  codeWordCount=0;
  if (readerInit) {
    codeWords[codeWordCount]=921;
    codeWordCount++;
  }
  if (eciMode != 3) {
    if (eciMode <= 899) {
      codeWords[codeWordCount]=927;
      codeWordCount++;
      codeWords[codeWordCount]=eciMode;
      codeWordCount++;
    }
    if ((eciMode >= 900) && (eciMode <= 810899)) {
      codeWords[codeWordCount]=926;
      codeWordCount++;
      codeWords[codeWordCount]=(eciMode / 900) - 1;
      codeWordCount++;
      codeWords[codeWordCount]=eciMode % 900;
      codeWordCount++;
    }
    if ((eciMode >= 810900) && (eciMode <= 811799)) {
      codeWords[codeWordCount]=925;
      codeWordCount++;
      codeWords[codeWordCount]=eciMode - 810900;
      codeWordCount++;
    }
  }
  for (i=0; i < blockIndex; i++) {
switch (blockType[i]) {
case TEX:
      boolean firstBlock=(i == 0);
    processText(blockCount,blockLength[i],firstBlock);
  break;
case BYT:
processBytes(blockCount,blockLength[i]);
break;
case NUM:
processNumbers(blockCount,blockLength[i]);
break;
default :
throw new OkapiException("String_Node_Str" + blockType[i]);
}
blockCount=blockCount + blockLength[i];
}
encodeInfo+="String_Node_Str";
for (i=0; i < codeWordCount; i++) {
encodeInfo+=Integer.toString(codeWords[i]) + "String_Node_Str";
}
encodeInfo+="String_Node_Str";
selectedECCLevel=preferredEccLevel;
if (selectedECCLevel < 0) {
selectedECCLevel=6;
if (codeWordCount <= 863) {
selectedECCLevel=5;
}
if (codeWordCount <= 320) {
selectedECCLevel=4;
}
if (codeWordCount <= 160) {
selectedECCLevel=3;
}
if (codeWordCount <= 40) {
selectedECCLevel=2;
}
}
int k=1 << (selectedECCLevel + 1);
int dataCodeWordCount=codeWordCount + k + 1;
if (!validateRows(3,90) || !validateColumns(1,30)) {
return false;
}
if (columns != null) {
if (rows != null) {
if (columns * rows < dataCodeWordCount) {
error_msg="String_Node_Str" + rows + "String_Node_Str"+ columns+ "String_Node_Str"+ dataCodeWordCount+ "String_Node_Str";
return false;
}
}
 else {
rows=(int)Math.ceil(dataCodeWordCount / (double)columns);
}
}
 else {
if (rows != null) {
columns=(int)Math.ceil(dataCodeWordCount / (double)rows);
}
 else {
columns=(int)(0.5 + Math.sqrt((dataCodeWordCount - 1) / 3.0));
rows=(int)Math.ceil(dataCodeWordCount / (double)columns);
}
}
if (!validateRows(3,90) || !validateColumns(1,30)) {
return false;
}
int paddingCount=(columns * rows) - codeWordCount - k- 1;
while (paddingCount > 0) {
codeWords[codeWordCount]=900;
codeWordCount++;
paddingCount--;
}
for (i=codeWordCount; i > 0; i--) {
codeWords[i]=codeWords[i - 1];
}
codeWordCount++;
codeWords[0]=codeWordCount;
switch (selectedECCLevel) {
case 1:
offset=2;
break;
case 2:
offset=6;
break;
case 3:
offset=14;
break;
case 4:
offset=30;
break;
case 5:
offset=62;
break;
case 6:
offset=126;
break;
case 7:
offset=254;
break;
case 8:
offset=510;
break;
default :
offset=0;
break;
}
for (loop=0; loop < 520; loop++) {
mccorrection[loop]=0;
}
for (i=0; i < codeWordCount; i++) {
total=(codeWords[i] + mccorrection[k - 1]) % 929;
for (j=k - 1; j > 0; j--) {
mccorrection[j]=(mccorrection[j - 1] + 929 - (total * COEFRS[offset + j]) % 929) % 929;
}
mccorrection[0]=(929 - (total * COEFRS[offset + j]) % 929) % 929;
}
encodeInfo+="String_Node_Str" + codeWordCount + "String_Node_Str";
encodeInfo+="String_Node_Str" + k + "String_Node_Str";
for (i=k - 1; i >= 0; i--) {
codeWords[codeWordCount++]=mccorrection[i] != 0 ? 929 - mccorrection[i] : 0;
}
if (codeWordCount > 929) {
error_msg="String_Node_Str" + codeWordCount + "String_Node_Str";
return false;
}
c1=(rows - 1) / 3;
c2=(selectedECCLevel * 3) + (rows - 1) % 3;
c3=columns - 1;
readable="String_Node_Str";
row_count=rows;
pattern=new String[rows];
row_height=new int[rows];
encodeInfo+="String_Node_Str" + columns + "String_Node_Str"+ rows+ "String_Node_Str";
for (i=0; i < rows; i++) {
for (j=0; j < columns; j++) {
dummy[j + 1]=codeWords[i * columns + j];
}
k=(i / 3) * 30;
switch (i % 3) {
case 0:
offset=0;
dummy[0]=k + c1;
dummy[columns + 1]=k + c3;
break;
case 1:
offset=929;
dummy[0]=k + c2;
dummy[columns + 1]=k + c1;
break;
case 2:
offset=1858;
dummy[0]=k + c3;
dummy[columns + 1]=k + c2;
break;
}
codebarre="String_Node_Str";
for (j=0; j <= columns + 1; j++) {
if (!(symbolMode == Mode.TRUNCATED && j > columns)) {
codebarre+=CODAGEMC[offset + dummy[j]];
codebarre+="String_Node_Str";
}
}
if (symbolMode != Mode.TRUNCATED) {
codebarre+="String_Node_Str";
}
bin="String_Node_Str";
for (j=0; j < codebarre.length(); j++) {
bin+=PDF_TTF[positionOf(codebarre.charAt(j),BR_SET)];
}
pattern[i]=bin2pat(bin);
row_height[i]=default_height;
}
return true;
}

Fixed version (ground truth):
private boolean processPdf417(){
  int i, j, blockCount, loop, offset;
  int[] mccorrection=new int[520];
  int total;
  int c1, c2, c3;
  int[] dummy=new int[35];
  String codebarre;
  int length=inputData.length;
  EncodingMode currentEncodingMode;
  int selectedECCLevel;
  String bin;
  blockIndex=0;
  blockCount=0;
  currentEncodingMode=chooseMode(inputData[blockCount]);
  for (i=0; i < 1000; i++) {
    blockLength[i]=0;
  }
  do {
    blockType[blockIndex]=currentEncodingMode;
    while ((blockType[blockIndex] == currentEncodingMode) && (blockCount < length)) {
      blockLength[blockIndex]++;
      blockCount++;
      if (blockCount < length) {
        currentEncodingMode=chooseMode(inputData[blockCount]);
      }
    }
    blockIndex++;
  }
 while (blockCount < length);
  for (i=0; i < blockIndex; i++) {
    if ((blockType[i] == EncodingMode.NUM) && (blockLength[i] > 44)) {
      for (j=blockIndex + 1; j > (i + 1); j--) {
        blockType[j]=blockType[j - 1];
        blockLength[j]=blockLength[j - 1];
      }
      blockType[i + 1]=blockType[i];
      blockLength[i + 1]=blockLength[i] - 44;
      blockLength[i]=44;
      blockIndex++;
    }
  }
  pdfSmooth();
  blockCount=0;
  codeWordCount=0;
  if (readerInit) {
    codeWords[codeWordCount]=921;
    codeWordCount++;
  }
  if (eciMode != 3) {
    if (eciMode <= 899) {
      codeWords[codeWordCount]=927;
      codeWordCount++;
      codeWords[codeWordCount]=eciMode;
      codeWordCount++;
    }
    if ((eciMode >= 900) && (eciMode <= 810899)) {
      codeWords[codeWordCount]=926;
      codeWordCount++;
      codeWords[codeWordCount]=(eciMode / 900) - 1;
      codeWordCount++;
      codeWords[codeWordCount]=eciMode % 900;
      codeWordCount++;
    }
    if ((eciMode >= 810900) && (eciMode <= 811799)) {
      codeWords[codeWordCount]=925;
      codeWordCount++;
      codeWords[codeWordCount]=eciMode - 810900;
      codeWordCount++;
    }
  }
  for (i=0; i < blockIndex; i++) {
switch (blockType[i]) {
case TEX:
      boolean firstBlock=(i == 0);
    processText(blockCount,blockLength[i],firstBlock);
  break;
case BYT:
EncodingMode lastMode=(i == 0 ? EncodingMode.TEX : blockType[i - 1]);
processBytes(blockCount,blockLength[i],lastMode);
break;
case NUM:
processNumbers(blockCount,blockLength[i]);
break;
default :
throw new OkapiException("String_Node_Str" + blockType[i]);
}
blockCount=blockCount + blockLength[i];
}
encodeInfo+="String_Node_Str";
for (i=0; i < codeWordCount; i++) {
encodeInfo+=Integer.toString(codeWords[i]) + "String_Node_Str";
}
encodeInfo+="String_Node_Str";
selectedECCLevel=preferredEccLevel;
if (selectedECCLevel < 0) {
selectedECCLevel=6;
if (codeWordCount <= 863) {
selectedECCLevel=5;
}
if (codeWordCount <= 320) {
selectedECCLevel=4;
}
if (codeWordCount <= 160) {
selectedECCLevel=3;
}
if (codeWordCount <= 40) {
selectedECCLevel=2;
}
}
int k=1 << (selectedECCLevel + 1);
int dataCodeWordCount=codeWordCount + k + 1;
if (!validateRows(3,90) || !validateColumns(1,30)) {
return false;
}
if (columns != null) {
if (rows != null) {
if (columns * rows < dataCodeWordCount) {
error_msg="String_Node_Str" + rows + "String_Node_Str"+ columns+ "String_Node_Str"+ dataCodeWordCount+ "String_Node_Str";
return false;
}
}
 else {
rows=(int)Math.ceil(dataCodeWordCount / (double)columns);
}
}
 else {
if (rows != null) {
columns=(int)Math.ceil(dataCodeWordCount / (double)rows);
}
 else {
columns=(int)(0.5 + Math.sqrt((dataCodeWordCount - 1) / 3.0));
rows=(int)Math.ceil(dataCodeWordCount / (double)columns);
}
}
if (!validateRows(3,90) || !validateColumns(1,30)) {
return false;
}
int paddingCount=(columns * rows) - codeWordCount - k- 1;
while (paddingCount > 0) {
codeWords[codeWordCount]=900;
codeWordCount++;
paddingCount--;
}
for (i=codeWordCount; i > 0; i--) {
codeWords[i]=codeWords[i - 1];
}
codeWordCount++;
codeWords[0]=codeWordCount;
switch (selectedECCLevel) {
case 1:
offset=2;
break;
case 2:
offset=6;
break;
case 3:
offset=14;
break;
case 4:
offset=30;
break;
case 5:
offset=62;
break;
case 6:
offset=126;
break;
case 7:
offset=254;
break;
case 8:
offset=510;
break;
default :
offset=0;
break;
}
for (loop=0; loop < 520; loop++) {
mccorrection[loop]=0;
}
for (i=0; i < codeWordCount; i++) {
total=(codeWords[i] + mccorrection[k - 1]) % 929;
for (j=k - 1; j > 0; j--) {
mccorrection[j]=(mccorrection[j - 1] + 929 - (total * COEFRS[offset + j]) % 929) % 929;
}
mccorrection[0]=(929 - (total * COEFRS[offset + j]) % 929) % 929;
}
encodeInfo+="String_Node_Str" + codeWordCount + "String_Node_Str";
encodeInfo+="String_Node_Str" + k + "String_Node_Str";
for (i=k - 1; i >= 0; i--) {
codeWords[codeWordCount++]=mccorrection[i] != 0 ? 929 - mccorrection[i] : 0;
}
if (codeWordCount > 929) {
error_msg="String_Node_Str" + codeWordCount + "String_Node_Str";
return false;
}
c1=(rows - 1) / 3;
c2=(selectedECCLevel * 3) + (rows - 1) % 3;
c3=columns - 1;
readable="String_Node_Str";
row_count=rows;
pattern=new String[rows];
row_height=new int[rows];
encodeInfo+="String_Node_Str" + columns + "String_Node_Str"+ rows+ "String_Node_Str";
for (i=0; i < rows; i++) {
for (j=0; j < columns; j++) {
dummy[j + 1]=codeWords[i * columns + j];
}
k=(i / 3) * 30;
switch (i % 3) {
case 0:
offset=0;
dummy[0]=k + c1;
dummy[columns + 1]=k + c3;
break;
case 1:
offset=929;
dummy[0]=k + c2;
dummy[columns + 1]=k + c1;
break;
case 2:
offset=1858;
dummy[0]=k + c3;
dummy[columns + 1]=k + c2;
break;
}
codebarre="String_Node_Str";
for (j=0; j <= columns + 1; j++) {
if (!(symbolMode == Mode.TRUNCATED && j > columns)) {
codebarre+=CODAGEMC[offset + dummy[j]];
codebarre+="String_Node_Str";
}
}
if (symbolMode != Mode.TRUNCATED) {
codebarre+="String_Node_Str";
}
bin="String_Node_Str";
for (j=0; j < codebarre.length(); j++) {
bin+=PDF_TTF[positionOf(codebarre.charAt(j),BR_SET)];
}
pattern[i]=bin2pat(bin);
row_height[i]=default_height;
}
return true;
}