Program: 51446
Project: 51446
Buggy source:
NativeEvaluator createEvaluator(RolapEvaluator evaluator,FunDef fun,Exp[] args){
  if (!isEnabled())   return null;
  if (!TopCountConstraint.isValidContext(evaluator)) {
    return null;
  }
  String funName=fun.getName();
  if ("String_Node_Str".equalsIgnoreCase(funName)) {
    ascending=false;
  }
 else   if ("String_Node_Str".equalsIgnoreCase(funName)) {
    ascending=true;
  }
 else {
    return null;
  }
  if (args.length < 2 || args.length > 3) {
    return null;
  }
  CrossJoinArg[] cargs=checkCrossJoinArg(args[0]);
  if (cargs == null) {
    return null;
  }
  if (isPreferInterpreter(cargs)) {
    return null;
  }
  if (!(args[1] instanceof Literal)) {
    return null;
  }
  int count=((Literal)args[1]).getIntValue();
  SchemaReader schemaReader=evaluator.getSchemaReader();
  DataSource ds=schemaReader.getDataSource();
  Connection con=null;
  try {
    con=ds.getConnection();
    SqlQuery sqlQuery=SqlTupleReader.newQuery(con,"String_Node_Str");
    RolapNativeSql sql=new RolapNativeSql(sqlQuery);
    String orderByExpr=null;
    if (args.length == 3) {
      orderByExpr=sql.generateTopCountOrderBy(args[2]);
      if (orderByExpr == null) {
        return null;
      }
    }
    LOGGER.debug("String_Node_Str");
    TupleConstraint constraint=new TopCountConstraint(cargs,evaluator,orderByExpr);
    SetEvaluator sev=new SetEvaluator(cargs,schemaReader,constraint);
    sev.setMaxRows(count);
    return sev;
  }
 catch (  SQLException e) {
    throw Util.newInternal(e,"String_Node_Str");
  }
 finally {
    if (con != null) {
      try {
        con.close();
      }
 catch (      SQLException e) {
        LOGGER.error(null,e);
      }
    }
  }
}

Fixed version (ground truth):
NativeEvaluator createEvaluator(RolapEvaluator evaluator,FunDef fun,Exp[] args){
  if (!isEnabled())   return null;
  if (!TopCountConstraint.isValidContext(evaluator)) {
    return null;
  }
  String funName=fun.getName();
  if ("String_Node_Str".equalsIgnoreCase(funName)) {
    ascending=false;
  }
 else   if ("String_Node_Str".equalsIgnoreCase(funName)) {
    ascending=true;
  }
 else {
    return null;
  }
  if (args.length < 2 || args.length > 3) {
    return null;
  }
  CrossJoinArg[] cargs=checkCrossJoinArg(args[0]);
  if (cargs == null) {
    return null;
  }
  if (isPreferInterpreter(cargs)) {
    return null;
  }
  if (!(args[1] instanceof Literal)) {
    return null;
  }
  int count=((Literal)args[1]).getIntValue();
  SchemaReader schemaReader=evaluator.getSchemaReader();
  DataSource ds=schemaReader.getDataSource();
  Connection con=null;
  try {
    con=ds.getConnection();
    SqlQuery sqlQuery=SqlTupleReader.newQuery(con,"String_Node_Str");
    RolapNativeSql sql=new RolapNativeSql(sqlQuery);
    String orderByExpr=null;
    if (args.length == 3) {
      orderByExpr=sql.generateTopCountOrderBy(args[2]);
      if (orderByExpr == null) {
        return null;
      }
    }
    LOGGER.debug("String_Node_Str");
    evaluator=overrideContext(evaluator,cargs,sql.getStoredMeasure());
    TupleConstraint constraint=new TopCountConstraint(cargs,evaluator,orderByExpr);
    SetEvaluator sev=new SetEvaluator(cargs,schemaReader,constraint);
    sev.setMaxRows(count);
    return sev;
  }
 catch (  SQLException e) {
    throw Util.newInternal(e,"String_Node_Str");
  }
 finally {
    if (con != null) {
      try {
        con.close();
      }
 catch (      SQLException e) {
        LOGGER.error(null,e);
      }
    }
  }
}