Program: 126566
Project: 126566
Buggy source:
/** 
 * DOC liuwu Comment method "replaceMEMO_SQL". aim: to resolve TDI-7487
 * @param original
 * @return
 */
public static String replaceCRLFInMEMO_SQL(String original){
  if (original == null || original.trim().length() == 0) {
    return original;
  }
  String result="String_Node_Str";
  int leftQuotes=original.indexOf("String_Node_Str");
  int rightQuotes=original.indexOf("String_Node_Str",leftQuotes + 1);
  int fakeRightQuotes=original.indexOf("String_Node_Str",leftQuotes + 1);
  while (rightQuotes == fakeRightQuotes + 1) {
    rightQuotes=original.indexOf("String_Node_Str",rightQuotes + 1);
    fakeRightQuotes=original.indexOf("String_Node_Str",fakeRightQuotes + 1);
  }
  int leftPrev=0;
  while (leftQuotes >= 0 && rightQuotes > leftQuotes) {
    if (leftQuotes > leftPrev) {
      result+=original.substring(leftPrev,leftQuotes);
    }
    if (leftQuotes < rightQuotes) {
      result+=original.substring(leftQuotes,rightQuotes + 1).replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
    }
    leftQuotes=original.indexOf("String_Node_Str",rightQuotes + 1);
    leftPrev=rightQuotes + 1;
    rightQuotes=original.indexOf("String_Node_Str",leftQuotes + 1);
    fakeRightQuotes=original.indexOf("String_Node_Str",leftQuotes + 1);
    while (rightQuotes == fakeRightQuotes + 1) {
      rightQuotes=original.indexOf("String_Node_Str",rightQuotes + 1);
      fakeRightQuotes=original.indexOf("String_Node_Str",fakeRightQuotes + 1);
    }
  }
  result+=original.substring(leftPrev);
  return result;
}

Fixed version (ground truth):
/** 
 * DOC liuwu Comment method "replaceMEMO_SQL". aim: to resolve TDI-7487
 * @param original
 * @return
 */
public static String replaceCRLFInMEMO_SQL(String original){
  if (original == null || original.trim().length() == 0) {
    return original;
  }
  String result="String_Node_Str";
  int leftQuotes=original.indexOf("String_Node_Str");
  int rightQuotes=original.indexOf("String_Node_Str",leftQuotes + 1);
  int fakeRightQuotes=original.indexOf("String_Node_Str",leftQuotes + 1);
  while (rightQuotes == fakeRightQuotes + 1) {
    rightQuotes=original.indexOf("String_Node_Str",rightQuotes + 1);
    fakeRightQuotes=original.indexOf("String_Node_Str",fakeRightQuotes + 1);
  }
  int leftPrev=0;
  while (leftQuotes >= 0 && rightQuotes > leftQuotes) {
    if (leftQuotes > leftPrev) {
      result+=original.substring(leftPrev,leftQuotes);
    }
    if (leftQuotes < rightQuotes) {
      result+=original.substring(leftQuotes,rightQuotes + 1).replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
    }
    leftQuotes=original.indexOf("String_Node_Str",rightQuotes + 1);
    leftPrev=rightQuotes + 1;
    rightQuotes=original.indexOf("String_Node_Str",leftQuotes + 1);
    fakeRightQuotes=original.indexOf("String_Node_Str",leftQuotes + 1);
    while (rightQuotes == fakeRightQuotes + 1) {
      rightQuotes=original.indexOf("String_Node_Str",rightQuotes + 1);
      fakeRightQuotes=original.indexOf("String_Node_Str",fakeRightQuotes + 1);
    }
  }
  result+=original.substring(leftPrev);
  return result;
}