Program: 58362
Project: 58362
Buggy source:
private boolean processMicroPdf417(){
  int i, k, j, blockCount, longueur, offset;
  int total;
  int LeftRAPStart, CentreRAPStart, RightRAPStart, StartCluster;
  int LeftRAP, CentreRAP, RightRAP, Cluster, flip, loop;
  String codebarre;
  int[] dummy=new int[5];
  int[] mccorrection=new int[50];
  int length=inputData.length;
  EncodingMode currentEncodingMode;
  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:
      processText(blockCount,blockLength[i],false);
    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";
if (!validateRows(4,44) || !validateColumns(1,4)) {
return false;
}
if (columns != null) {
int max;
switch (columns) {
case 1:
max=20;
break;
case 2:
max=37;
break;
case 3:
max=82;
break;
case 4:
max=126;
break;
default :
throw new OkapiException("String_Node_Str" + columns);
}
if (codeWordCount > max) {
error_msg="String_Node_Str" + columns + "String_Node_Str"+ codeWordCount+ "String_Node_Str";
return false;
}
}
int variant=getMicroPdf417Variant(codeWordCount,columns,rows);
variant--;
columns=MICRO_VARIANTS[variant];
rows=MICRO_VARIANTS[variant + 34];
k=MICRO_VARIANTS[variant + 68];
longueur=(columns * rows) - k;
i=longueur - codeWordCount;
offset=MICRO_VARIANTS[variant + 102];
encodeInfo+="String_Node_Str" + longueur + "String_Node_Str";
encodeInfo+="String_Node_Str" + k + "String_Node_Str";
while (i > 0) {
codeWords[codeWordCount]=900;
codeWordCount++;
i--;
}
longueur=codeWordCount;
for (loop=0; loop < 50; loop++) {
mccorrection[loop]=0;
}
for (i=0; i < longueur; i++) {
total=(codeWords[i] + mccorrection[k - 1]) % 929;
for (j=k - 1; j >= 0; j--) {
if (j == 0) {
mccorrection[j]=(929 - (total * MICRO_COEFFS[offset + j]) % 929) % 929;
}
 else {
mccorrection[j]=(mccorrection[j - 1] + 929 - (total * MICRO_COEFFS[offset + j]) % 929) % 929;
}
}
}
for (j=0; j < k; j++) {
if (mccorrection[j] != 0) {
mccorrection[j]=929 - mccorrection[j];
}
}
for (i=k - 1; i >= 0; i--) {
codeWords[codeWordCount]=mccorrection[i];
codeWordCount++;
}
LeftRAPStart=RAP_TABLE[variant];
CentreRAPStart=RAP_TABLE[variant + 34];
RightRAPStart=RAP_TABLE[variant + 68];
StartCluster=RAP_TABLE[variant + 102] / 3;
LeftRAP=LeftRAPStart;
CentreRAP=CentreRAPStart;
RightRAP=RightRAPStart;
Cluster=StartCluster;
readable="String_Node_Str";
pattern=new String[rows];
row_count=rows;
row_height=new int[rows];
encodeInfo+="String_Node_Str" + columns + "String_Node_Str"+ row_count+ "String_Node_Str";
for (i=0; i < rows; i++) {
codebarre="String_Node_Str";
offset=929 * Cluster;
for (j=0; j < 5; j++) {
dummy[j]=0;
}
for (j=0; j < columns; j++) {
dummy[j + 1]=codeWords[i * columns + j];
}
codebarre+=RAPLR[LeftRAP];
codebarre+="String_Node_Str";
codebarre+=CODAGEMC[offset + dummy[1]];
codebarre+="String_Node_Str";
if (columns == 3) {
codebarre+=RAPC[CentreRAP];
}
if (columns >= 2) {
codebarre+="String_Node_Str";
codebarre+=CODAGEMC[offset + dummy[2]];
codebarre+="String_Node_Str";
}
if (columns == 4) {
codebarre+=RAPC[CentreRAP];
}
if (columns >= 3) {
codebarre+="String_Node_Str";
codebarre+=CODAGEMC[offset + dummy[3]];
codebarre+="String_Node_Str";
}
if (columns == 4) {
codebarre+="String_Node_Str";
codebarre+=CODAGEMC[offset + dummy[4]];
codebarre+="String_Node_Str";
}
codebarre+=RAPLR[RightRAP];
codebarre+="String_Node_Str";
flip=1;
bin="String_Node_Str";
for (loop=0; loop < codebarre.length(); loop++) {
if ((codebarre.charAt(loop) >= '0') && (codebarre.charAt(loop) <= '9')) {
for (k=0; k < Character.getNumericValue(codebarre.charAt(loop)); k++) {
if (flip == 0) {
bin+='0';
}
 else {
bin+='1';
}
}
if (flip == 0) {
flip=1;
}
 else {
flip=0;
}
}
 else {
bin+=PDF_TTF[positionOf(codebarre.charAt(loop),BR_SET)];
}
}
pattern[i]=bin2pat(bin);
row_height[i]=default_height;
LeftRAP++;
CentreRAP++;
RightRAP++;
Cluster++;
if (LeftRAP == 53) {
LeftRAP=1;
}
if (CentreRAP == 53) {
CentreRAP=1;
}
if (RightRAP == 53) {
RightRAP=1;
}
if (Cluster == 3) {
Cluster=0;
}
}
return true;
}

Fixed version (ground truth):
private boolean processMicroPdf417(){
  int i, k, j, blockCount, longueur, offset;
  int total;
  int LeftRAPStart, CentreRAPStart, RightRAPStart, StartCluster;
  int LeftRAP, CentreRAP, RightRAP, Cluster, flip, loop;
  String codebarre;
  int[] dummy=new int[5];
  int[] mccorrection=new int[50];
  int length=inputData.length;
  EncodingMode currentEncodingMode;
  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:
      processText(blockCount,blockLength[i],false);
    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";
if (!validateRows(4,44) || !validateColumns(1,4)) {
return false;
}
if (columns != null) {
int max;
switch (columns) {
case 1:
max=20;
break;
case 2:
max=37;
break;
case 3:
max=82;
break;
case 4:
max=126;
break;
default :
throw new OkapiException("String_Node_Str" + columns);
}
if (codeWordCount > max) {
error_msg="String_Node_Str" + columns + "String_Node_Str"+ codeWordCount+ "String_Node_Str";
return false;
}
}
int variant=getMicroPdf417Variant(codeWordCount,columns,rows);
variant--;
columns=MICRO_VARIANTS[variant];
rows=MICRO_VARIANTS[variant + 34];
k=MICRO_VARIANTS[variant + 68];
longueur=(columns * rows) - k;
i=longueur - codeWordCount;
offset=MICRO_VARIANTS[variant + 102];
encodeInfo+="String_Node_Str" + longueur + "String_Node_Str";
encodeInfo+="String_Node_Str" + k + "String_Node_Str";
while (i > 0) {
codeWords[codeWordCount]=900;
codeWordCount++;
i--;
}
longueur=codeWordCount;
for (loop=0; loop < 50; loop++) {
mccorrection[loop]=0;
}
for (i=0; i < longueur; i++) {
total=(codeWords[i] + mccorrection[k - 1]) % 929;
for (j=k - 1; j >= 0; j--) {
if (j == 0) {
mccorrection[j]=(929 - (total * MICRO_COEFFS[offset + j]) % 929) % 929;
}
 else {
mccorrection[j]=(mccorrection[j - 1] + 929 - (total * MICRO_COEFFS[offset + j]) % 929) % 929;
}
}
}
for (j=0; j < k; j++) {
if (mccorrection[j] != 0) {
mccorrection[j]=929 - mccorrection[j];
}
}
for (i=k - 1; i >= 0; i--) {
codeWords[codeWordCount]=mccorrection[i];
codeWordCount++;
}
LeftRAPStart=RAP_TABLE[variant];
CentreRAPStart=RAP_TABLE[variant + 34];
RightRAPStart=RAP_TABLE[variant + 68];
StartCluster=RAP_TABLE[variant + 102] / 3;
LeftRAP=LeftRAPStart;
CentreRAP=CentreRAPStart;
RightRAP=RightRAPStart;
Cluster=StartCluster;
readable="String_Node_Str";
pattern=new String[rows];
row_count=rows;
row_height=new int[rows];
encodeInfo+="String_Node_Str" + columns + "String_Node_Str"+ row_count+ "String_Node_Str";
for (i=0; i < rows; i++) {
codebarre="String_Node_Str";
offset=929 * Cluster;
for (j=0; j < 5; j++) {
dummy[j]=0;
}
for (j=0; j < columns; j++) {
dummy[j + 1]=codeWords[i * columns + j];
}
codebarre+=RAPLR[LeftRAP];
codebarre+="String_Node_Str";
codebarre+=CODAGEMC[offset + dummy[1]];
codebarre+="String_Node_Str";
if (columns == 3) {
codebarre+=RAPC[CentreRAP];
}
if (columns >= 2) {
codebarre+="String_Node_Str";
codebarre+=CODAGEMC[offset + dummy[2]];
codebarre+="String_Node_Str";
}
if (columns == 4) {
codebarre+=RAPC[CentreRAP];
}
if (columns >= 3) {
codebarre+="String_Node_Str";
codebarre+=CODAGEMC[offset + dummy[3]];
codebarre+="String_Node_Str";
}
if (columns == 4) {
codebarre+="String_Node_Str";
codebarre+=CODAGEMC[offset + dummy[4]];
codebarre+="String_Node_Str";
}
codebarre+=RAPLR[RightRAP];
codebarre+="String_Node_Str";
flip=1;
bin="String_Node_Str";
for (loop=0; loop < codebarre.length(); loop++) {
if ((codebarre.charAt(loop) >= '0') && (codebarre.charAt(loop) <= '9')) {
for (k=0; k < Character.getNumericValue(codebarre.charAt(loop)); k++) {
if (flip == 0) {
bin+='0';
}
 else {
bin+='1';
}
}
if (flip == 0) {
flip=1;
}
 else {
flip=0;
}
}
 else {
bin+=PDF_TTF[positionOf(codebarre.charAt(loop),BR_SET)];
}
}
pattern[i]=bin2pat(bin);
row_height[i]=default_height;
LeftRAP++;
CentreRAP++;
RightRAP++;
Cluster++;
if (LeftRAP == 53) {
LeftRAP=1;
}
if (CentreRAP == 53) {
CentreRAP=1;
}
if (RightRAP == 53) {
RightRAP=1;
}
if (Cluster == 3) {
Cluster=0;
}
}
return true;
}