Program: 52348
Project: 52348
Buggy source:
/** 
 * Find the epeople that match the search query across firstname, lastname or email.  This method also allows offsets and limits for pagination purposes. 
 * @param context DSpace context
 * @param query The search string
 * @param offset Inclusive offset 
 * @param limit Maximum number of matches returned
 * @return array of EPerson objects
 */
public static EPerson[] search(Context context,String query,int offset,int limit) throws SQLException {
  String params="String_Node_Str" + query.toLowerCase() + "String_Node_Str";
  String dbquery="String_Node_Str" + "String_Node_Str";
  if (offset >= 0 && limit > 0) {
    dbquery+="String_Node_Str" + limit + "String_Node_Str"+ offset;
  }
  Integer int_param;
  try {
    int_param=Integer.valueOf(query);
  }
 catch (  NumberFormatException e) {
    int_param=new Integer(-1);
  }
  TableRowIterator rows=DatabaseManager.query(context,dbquery,new Object[]{int_param,params,params,params});
  List epeopleRows=rows.toList();
  EPerson[] epeople=new EPerson[epeopleRows.size()];
  for (int i=0; i < epeopleRows.size(); i++) {
    TableRow row=(TableRow)epeopleRows.get(i);
    EPerson fromCache=(EPerson)context.fromCache(EPerson.class,row.getIntColumn("String_Node_Str"));
    if (fromCache != null) {
      epeople[i]=fromCache;
    }
 else {
      epeople[i]=new EPerson(context,row);
    }
  }
  return epeople;
}

Fixed version (ground truth):
/** 
 * Find the epeople that match the search query across firstname, lastname or email.  This method also allows offsets and limits for pagination purposes. 
 * @param context DSpace context
 * @param query The search string
 * @param offset Inclusive offset 
 * @param limit Maximum number of matches returned
 * @return array of EPerson objects
 */
public static EPerson[] search(Context context,String query,int offset,int limit) throws SQLException {
  String params="String_Node_Str" + query.toLowerCase() + "String_Node_Str";
  StringBuffer queryBuf=new StringBuffer();
  queryBuf.append("String_Node_Str");
  queryBuf.append("String_Node_Str");
  if ("String_Node_Str".equals(ConfigurationManager.getProperty("String_Node_Str"))) {
    if (limit > 0 || offset > 0) {
      queryBuf.insert(0,"String_Node_Str");
      queryBuf.append("String_Node_Str");
    }
    if (limit > 0) {
      queryBuf.append("String_Node_Str");
      if (offset > 0)       limit+=offset;
    }
    if (offset > 0) {
      queryBuf.insert(0,"String_Node_Str");
      queryBuf.append("String_Node_Str");
    }
  }
 else {
    if (limit > 0)     queryBuf.append("String_Node_Str");
    if (offset > 0)     queryBuf.append("String_Node_Str");
  }
  String dbquery=queryBuf.toString();
  Integer int_param;
  try {
    int_param=Integer.valueOf(query);
  }
 catch (  NumberFormatException e) {
    int_param=new Integer(-1);
  }
  Object[] paramArr=new Object[]{int_param,params,params,params};
  if (limit > 0 && offset > 0)   paramArr=new Object[]{int_param,params,params,params,limit,offset};
 else   if (limit > 0)   paramArr=new Object[]{int_param,params,params,params,limit};
 else   if (offset > 0)   paramArr=new Object[]{int_param,params,params,params,offset};
  TableRowIterator rows=DatabaseManager.query(context,dbquery,paramArr);
  List epeopleRows=rows.toList();
  EPerson[] epeople=new EPerson[epeopleRows.size()];
  for (int i=0; i < epeopleRows.size(); i++) {
    TableRow row=(TableRow)epeopleRows.get(i);
    EPerson fromCache=(EPerson)context.fromCache(EPerson.class,row.getIntColumn("String_Node_Str"));
    if (fromCache != null) {
      epeople[i]=fromCache;
    }
 else {
      epeople[i]=new EPerson(context,row);
    }
  }
  return epeople;
}