Program: 50865
Project: 50865
Buggy source:
/** 
 * Returns a the XML of the foodmart schema, adding dimension definitions to the definition of a given cube.
 */
private String substituteSchema(String rawSchema,String cubeName,String dimensionDefs,String measureDefs,String memberDefs,String namedSetDefs){
  String s=rawSchema;
  int h=s.indexOf("String_Node_Str" + cubeName + "String_Node_Str");
  int end;
  if (h < 0) {
    h=s.indexOf("String_Node_Str" + cubeName + "String_Node_Str");
  }
  if (h < 0) {
    h=s.indexOf("String_Node_Str" + cubeName + "String_Node_Str");
    if (h < 0) {
      h=s.indexOf("String_Node_Str" + cubeName + "String_Node_Str");
    }
    if (h < 0) {
      throw new RuntimeException("String_Node_Str" + cubeName + "String_Node_Str");
    }
 else {
      end=s.indexOf("String_Node_Str",h);
    }
  }
 else {
    end=s.indexOf("String_Node_Str",h);
  }
  if (dimensionDefs != null) {
    int i=s.indexOf("String_Node_Str",h);
    s=s.substring(0,i) + dimensionDefs + s.substring(i);
  }
  if (measureDefs != null) {
    int i=s.indexOf("String_Node_Str",h);
    if (i < 0 || i > end) {
      i=end;
    }
    s=s.substring(0,i) + measureDefs + s.substring(i);
  }
  if (memberDefs != null) {
    int i=s.indexOf("String_Node_Str",h);
    if (i < 0 || i > end) {
      i=end;
    }
    s=s.substring(0,i) + memberDefs + s.substring(i);
  }
  if (namedSetDefs != null) {
    int i=s.indexOf("String_Node_Str",h);
    if (i < 0 || i > end) {
      i=end;
    }
    s=s.substring(0,i) + namedSetDefs + s.substring(i);
  }
  return s;
}

Fixed version (ground truth):
/** 
 * Returns a the XML of the foodmart schema, adding dimension definitions to the definition of a given cube.
 */
private String substituteSchema(String rawSchema,String cubeName,String dimensionDefs,String measureDefs,String memberDefs,String namedSetDefs){
  String s=rawSchema;
  int h=s.indexOf("String_Node_Str" + cubeName + "String_Node_Str");
  int end;
  if (h < 0) {
    h=s.indexOf("String_Node_Str" + cubeName + "String_Node_Str");
  }
  if (h < 0) {
    h=s.indexOf("String_Node_Str" + cubeName + "String_Node_Str");
    if (h < 0) {
      h=s.indexOf("String_Node_Str" + cubeName + "String_Node_Str");
    }
    if (h < 0) {
      throw new RuntimeException("String_Node_Str" + cubeName + "String_Node_Str");
    }
 else {
      end=s.indexOf("String_Node_Str",h);
    }
  }
 else {
    end=s.indexOf("String_Node_Str",h);
  }
  if (dimensionDefs != null) {
    int i=s.indexOf("String_Node_Str",h);
    s=s.substring(0,i) + dimensionDefs + s.substring(i);
  }
  if (measureDefs != null) {
    int i=s.indexOf("String_Node_Str",h);
    if (i < 0 || i > end) {
      i=end;
    }
    s=s.substring(0,i) + measureDefs + s.substring(i);
    if (i == end) {
      i=s.indexOf("String_Node_Str",h);
      if (i < 0 || i > end) {
        i=end;
      }
      s=s.substring(0,i) + measureDefs + s.substring(i);
    }
  }
  if (memberDefs != null) {
    int i=s.indexOf("String_Node_Str",h);
    if (i < 0 || i > end) {
      i=end;
    }
    s=s.substring(0,i) + memberDefs + s.substring(i);
  }
  if (namedSetDefs != null) {
    int i=s.indexOf("String_Node_Str",h);
    if (i < 0 || i > end) {
      i=end;
    }
    s=s.substring(0,i) + namedSetDefs + s.substring(i);
  }
  return s;
}