Program: 168898
Project: 168898
Buggy source:
@Override public void applySql(StringBuilder sqlSb,boolean isSubquery,String limit,String offset){
  if (offset != null) {
    int selectIndex=SqlUtils.indexOfSelect(sqlSb);
    String[] aliases=SqlUtils.getSelectItemAliases(sqlSb,selectIndex);
    StringBuilder selectClauseSb=new StringBuilder(60 + aliases.length * 20);
    selectClauseSb.append("String_Node_Str");
    for (int i=0; i < aliases.length; i++) {
      selectClauseSb.append(aliases[i]);
      selectClauseSb.append(',');
    }
    selectClauseSb.setCharAt(selectClauseSb.length() - 1,' ');
    selectClauseSb.append("String_Node_Str");
    sqlSb.ensureCapacity(sqlSb.length() + 50 + selectClauseSb.length());
    sqlSb.insert(selectIndex,selectClauseSb);
  }
 else {
    sqlSb.ensureCapacity(sqlSb.length() + 30);
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str");
  }
  if (offset != null) {
    if (limit != null) {
      sqlSb.append("String_Node_Str");
      sqlSb.append(limit);
      sqlSb.append("String_Node_Str");
      sqlSb.append(offset);
      sqlSb.append("String_Node_Str");
    }
 else {
      sqlSb.append("String_Node_Str").append(offset);
    }
  }
}

Fixed version (ground truth):
@Override public void applySql(StringBuilder sqlSb,boolean isSubquery,String limit,String offset){
  final int appendIndex;
  if (offset != null) {
    final int selectIndex=SqlUtils.indexOfSelect(sqlSb);
    String[] aliases=SqlUtils.getSelectItemAliases(sqlSb,selectIndex);
    int[] finalTableSubqueryBounds=SqlUtils.indexOfFinalTableSubquery(sqlSb,selectIndex);
    StringBuilder selectClauseSb=new StringBuilder(80 + aliases.length * 20);
    selectClauseSb.append("String_Node_Str");
    Map<Integer,String> sequences=null;
    for (int i=0; i < aliases.length; i++) {
      if (aliases[i].regionMatches(true,0,"String_Node_Str",0,15)) {
        if (sequences == null) {
          sequences=new LinkedHashMap<Integer,String>();
        }
        sequences.put(i,aliases[i]);
      }
      selectClauseSb.append(aliases[i]);
      selectClauseSb.append(',');
    }
    selectClauseSb.setCharAt(selectClauseSb.length() - 1,' ');
    selectClauseSb.append("String_Node_Str");
    sqlSb.ensureCapacity(sqlSb.length() + 120 + selectClauseSb.length());
    sqlSb.insert(Math.max(selectIndex,finalTableSubqueryBounds[0]),selectClauseSb);
    int removedChars=0;
    if (sequences != null) {
      int startIndex=selectIndex + selectClauseSb.length();
      for (      Map.Entry<Integer,String> sequenceEntry : sequences.entrySet()) {
        String sequence=sequenceEntry.getValue();
        int index=sqlSb.indexOf(sequence,startIndex);
        if (sequenceEntry.getKey().intValue() == 0) {
          int currentIdx=index + sequence.length();
          while (Character.isWhitespace(sqlSb.charAt(currentIdx))) {
            currentIdx++;
          }
          currentIdx++;
          int diff=currentIdx - index;
          sqlSb.replace(index,currentIdx,"String_Node_Str");
          startIndex-=diff;
          removedChars+=diff;
        }
 else {
          int currentIdx=index - 1;
          while (Character.isWhitespace(sqlSb.charAt(currentIdx))) {
            currentIdx--;
          }
          int end=index + sequence.length();
          int diff=end - currentIdx;
          sqlSb.replace(currentIdx,end,"String_Node_Str");
          startIndex-=end - currentIdx;
          removedChars+=diff;
        }
      }
    }
    appendIndex=(finalTableSubqueryBounds[1] + selectClauseSb.length()) - removedChars;
  }
 else {
    appendIndex=SqlUtils.indexOfFinalTableSubquery(sqlSb,0)[1];
    StringBuilder limitSb=new StringBuilder(40);
    limitSb.append("String_Node_Str").append(limit).append("String_Node_Str");
    sqlSb.insert(appendIndex,limitSb);
  }
  if (offset != null) {
    if (limit != null) {
      StringBuilder limitSb=new StringBuilder(120);
      limitSb.append("String_Node_Str");
      limitSb.append(limit);
      limitSb.append("String_Node_Str");
      limitSb.append(offset);
      limitSb.append("String_Node_Str");
      sqlSb.insert(appendIndex,limitSb);
    }
 else {
      StringBuilder limitSb=new StringBuilder(30);
      limitSb.append("String_Node_Str").append(offset);
      sqlSb.insert(appendIndex,limitSb);
    }
  }
}