Program: 58368
Project: 58368
Buggy source:
@Override public boolean encode(){
  int size, modules, dark, error_number;
  int auto_layers, min_layers, layers, auto_ecc_level, min_ecc_level, ecc_level;
  int x, y, i;
  int data_cw, input_latch=0;
  int data_max;
  int length;
  String bin;
  int qmarksBefore, qmarksAfter;
  for (i=0; i < 1460; i++) {
    word[i]=0;
  }
  if (debug) {
    System.out.printf("String_Node_Str",content);
  }
  try {
    qmarksBefore=0;
    for (i=0; i < content.length(); i++) {
      if (content.charAt(i) == '?') {
        qmarksBefore++;
      }
    }
    inputBytes=content.getBytes("String_Node_Str");
    qmarksAfter=0;
    for (i=0; i < inputBytes.length; i++) {
      if (inputBytes[i] == '?') {
        qmarksAfter++;
      }
    }
    if (qmarksBefore == qmarksAfter) {
      inputIntArray=new int[inputBytes.length];
      length=0;
      for (i=0; i < inputBytes.length; i++) {
        if (((inputBytes[i] & 0xFF) >= 0xA1) && ((inputBytes[i] & 0xFF) <= 0xF7)) {
          inputIntArray[length]=((inputBytes[i] & 0xFF) * 256) + (inputBytes[i + 1] & 0xFF);
          i++;
          length++;
        }
 else {
          inputIntArray[length]=inputBytes[i] & 0xFF;
          length++;
        }
      }
      if (debug) {
        System.out.printf("String_Node_Str");
      }
      eciMode=29;
    }
 else {
      eciProcess();
      length=inputBytes.length;
      inputIntArray=new int[length];
      for (i=0; i < length; i++) {
        inputIntArray[i]=inputBytes[i] & 0xFF;
      }
    }
  }
 catch (  UnsupportedEncodingException e) {
    error_msg="String_Node_Str";
    return false;
  }
  error_number=encodeGridMatrixBinary(length,readerInit);
  if (error_number != 0) {
    error_msg="String_Node_Str";
    return false;
  }
  data_cw=binary.length() / 7;
  auto_layers=0;
  for (i=0; i < 13; i++) {
    if (gm_recommend_cw[i] < data_cw) {
      auto_layers=i + 1;
    }
  }
  min_layers=13;
  for (i=12; i > 0; i--) {
    if (gm_max_cw[(i - 1)] >= data_cw) {
      min_layers=i;
    }
  }
  layers=auto_layers;
  auto_ecc_level=3;
  if (layers == 1) {
    auto_ecc_level=5;
  }
  if ((layers == 2) || (layers == 3)) {
    auto_ecc_level=4;
  }
  min_ecc_level=1;
  if (layers == 1) {
    min_ecc_level=4;
  }
  if ((layers == 2) || (layers == 3)) {
    min_ecc_level=2;
  }
  ecc_level=auto_ecc_level;
  if ((preferredVersion >= 1) && (preferredVersion <= 13)) {
    input_latch=1;
    if (preferredVersion > min_layers) {
      layers=preferredVersion;
    }
 else {
      layers=min_layers;
    }
  }
  if (input_latch == 1) {
    auto_ecc_level=3;
    if (layers == 1) {
      auto_ecc_level=5;
    }
    if ((layers == 2) || (layers == 3)) {
      auto_ecc_level=4;
    }
    ecc_level=auto_ecc_level;
    if (data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)]) {
      layers++;
    }
  }
  if (input_latch == 0) {
    if ((preferredEccLevel >= 1) && (preferredEccLevel <= 5)) {
      if (preferredEccLevel > min_ecc_level) {
        ecc_level=preferredEccLevel;
      }
 else {
        ecc_level=min_ecc_level;
      }
    }
    if (data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)]) {
      do {
        layers++;
      }
 while ((data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)]) && (layers <= 13));
    }
  }
  data_max=1313;
switch (ecc_level) {
case 2:
    data_max=1167;
  break;
case 3:
data_max=1021;
break;
case 4:
data_max=875;
break;
case 5:
data_max=729;
break;
}
if (data_cw > data_max) {
error_msg="String_Node_Str";
return false;
}
addErrorCorrection(data_cw,layers,ecc_level);
size=6 + (layers * 12);
modules=1 + (layers * 2);
encodeInfo+="String_Node_Str" + layers + "String_Node_Str";
encodeInfo+="String_Node_Str" + ecc_level + "String_Node_Str";
encodeInfo+="String_Node_Str" + data_cw + "String_Node_Str";
encodeInfo+="String_Node_Str" + gm_data_codewords[((layers - 1) * 5) + (ecc_level - 1)] + "String_Node_Str";
encodeInfo+="String_Node_Str" + modules + "String_Node_Str"+ modules+ "String_Node_Str";
grid=new boolean[size * size];
for (x=0; x < size; x++) {
for (y=0; y < size; y++) {
grid[(y * size) + x]=false;
}
}
placeDataInGrid(modules,size);
addLayerId(size,layers,modules,ecc_level);
for (x=0; x < modules; x++) {
dark=1 - (x & 1);
for (y=0; y < modules; y++) {
if (dark == 1) {
for (i=0; i < 5; i++) {
grid[((y * 6) * size) + (x * 6) + i]=true;
grid[(((y * 6) + 5) * size) + (x * 6) + i]=true;
grid[(((y * 6) + i) * size) + (x * 6)]=true;
grid[(((y * 6) + i) * size) + (x * 6) + 5]=true;
}
grid[(((y * 6) + 5) * size) + (x * 6) + 5]=true;
dark=0;
}
 else {
dark=1;
}
}
}
symbol_width=size;
row_count=size;
row_height=new int[row_count];
pattern=new String[row_count];
for (x=0; x < size; x++) {
bin="String_Node_Str";
for (y=0; y < size; y++) {
if (grid[(x * size) + y]) {
bin+="String_Node_Str";
}
 else {
bin+="String_Node_Str";
}
}
row_height[x]=1;
pattern[x]=bin2pat(bin);
}
plotSymbol();
return true;
}

Fixed version (ground truth):
@Override public boolean encode(){
  int size, modules, dark, error_number;
  int auto_layers, min_layers, layers, auto_ecc_level, min_ecc_level, ecc_level;
  int x, y, i;
  int data_cw, input_latch=0;
  int data_max;
  int length;
  String bin;
  int qmarksBefore, qmarksAfter;
  for (i=0; i < 1460; i++) {
    word[i]=0;
  }
  if (debug) {
    System.out.printf("String_Node_Str",content);
  }
  try {
    qmarksBefore=0;
    for (i=0; i < content.length(); i++) {
      if (content.charAt(i) == '?') {
        qmarksBefore++;
      }
    }
    inputBytes=content.getBytes("String_Node_Str");
    qmarksAfter=0;
    for (i=0; i < inputBytes.length; i++) {
      if (inputBytes[i] == '?') {
        qmarksAfter++;
      }
    }
    if (qmarksBefore == qmarksAfter) {
      inputIntArray=new int[inputBytes.length];
      length=0;
      for (i=0; i < inputBytes.length; i++) {
        if (((inputBytes[i] & 0xFF) >= 0xA1) && ((inputBytes[i] & 0xFF) <= 0xF7)) {
          inputIntArray[length]=((inputBytes[i] & 0xFF) * 256) + (inputBytes[i + 1] & 0xFF);
          i++;
          length++;
        }
 else {
          inputIntArray[length]=inputBytes[i] & 0xFF;
          length++;
        }
      }
      if (debug) {
        System.out.printf("String_Node_Str");
      }
      eciMode=29;
    }
 else {
      eciProcess();
      length=inputBytes.length;
      inputIntArray=new int[length];
      for (i=0; i < length; i++) {
        inputIntArray[i]=inputBytes[i] & 0xFF;
      }
    }
  }
 catch (  UnsupportedEncodingException e) {
    error_msg="String_Node_Str";
    return false;
  }
  error_number=encodeGridMatrixBinary(length,readerInit);
  if (error_number != 0) {
    error_msg="String_Node_Str";
    return false;
  }
  data_cw=binary.length() / 7;
  auto_layers=1;
  for (i=0; i < 13; i++) {
    if (gm_recommend_cw[i] < data_cw) {
      auto_layers=i + 1;
    }
  }
  min_layers=13;
  for (i=12; i > 0; i--) {
    if (gm_max_cw[(i - 1)] >= data_cw) {
      min_layers=i;
    }
  }
  layers=auto_layers;
  auto_ecc_level=3;
  if (layers == 1) {
    auto_ecc_level=5;
  }
  if ((layers == 2) || (layers == 3)) {
    auto_ecc_level=4;
  }
  min_ecc_level=1;
  if (layers == 1) {
    min_ecc_level=4;
  }
  if ((layers == 2) || (layers == 3)) {
    min_ecc_level=2;
  }
  ecc_level=auto_ecc_level;
  if ((preferredVersion >= 1) && (preferredVersion <= 13)) {
    input_latch=1;
    if (preferredVersion > min_layers) {
      layers=preferredVersion;
    }
 else {
      layers=min_layers;
    }
  }
  if (input_latch == 1) {
    auto_ecc_level=3;
    if (layers == 1) {
      auto_ecc_level=5;
    }
    if ((layers == 2) || (layers == 3)) {
      auto_ecc_level=4;
    }
    ecc_level=auto_ecc_level;
    if (data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)]) {
      layers++;
    }
  }
  if (input_latch == 0) {
    if ((preferredEccLevel >= 1) && (preferredEccLevel <= 5)) {
      if (preferredEccLevel > min_ecc_level) {
        ecc_level=preferredEccLevel;
      }
 else {
        ecc_level=min_ecc_level;
      }
    }
    if (data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)]) {
      do {
        layers++;
      }
 while ((data_cw > gm_data_codewords[(5 * (layers - 1)) + (ecc_level - 1)]) && (layers <= 13));
    }
  }
  data_max=1313;
switch (ecc_level) {
case 2:
    data_max=1167;
  break;
case 3:
data_max=1021;
break;
case 4:
data_max=875;
break;
case 5:
data_max=729;
break;
}
if (data_cw > data_max) {
error_msg="String_Node_Str";
return false;
}
addErrorCorrection(data_cw,layers,ecc_level);
size=6 + (layers * 12);
modules=1 + (layers * 2);
encodeInfo+="String_Node_Str" + layers + "String_Node_Str";
encodeInfo+="String_Node_Str" + ecc_level + "String_Node_Str";
encodeInfo+="String_Node_Str" + data_cw + "String_Node_Str";
encodeInfo+="String_Node_Str" + gm_data_codewords[((layers - 1) * 5) + (ecc_level - 1)] + "String_Node_Str";
encodeInfo+="String_Node_Str" + modules + "String_Node_Str"+ modules+ "String_Node_Str";
grid=new boolean[size * size];
for (x=0; x < size; x++) {
for (y=0; y < size; y++) {
grid[(y * size) + x]=false;
}
}
placeDataInGrid(modules,size);
addLayerId(size,layers,modules,ecc_level);
for (x=0; x < modules; x++) {
dark=1 - (x & 1);
for (y=0; y < modules; y++) {
if (dark == 1) {
for (i=0; i < 5; i++) {
grid[((y * 6) * size) + (x * 6) + i]=true;
grid[(((y * 6) + 5) * size) + (x * 6) + i]=true;
grid[(((y * 6) + i) * size) + (x * 6)]=true;
grid[(((y * 6) + i) * size) + (x * 6) + 5]=true;
}
grid[(((y * 6) + 5) * size) + (x * 6) + 5]=true;
dark=0;
}
 else {
dark=1;
}
}
}
symbol_width=size;
row_count=size;
row_height=new int[row_count];
pattern=new String[row_count];
for (x=0; x < size; x++) {
bin="String_Node_Str";
for (y=0; y < size; y++) {
if (grid[(x * size) + y]) {
bin+="String_Node_Str";
}
 else {
bin+="String_Node_Str";
}
}
row_height[x]=1;
pattern[x]=bin2pat(bin);
}
plotSymbol();
return true;
}