Program: 71413
Project: 71413
Buggy source:
protected void prepareQuery() throws DataException {
  try {
    IBinding[] bindings=null;
    if (this.queryDefn.getSourceQuery() instanceof SubqueryLocator) {
      this.queryResults=engine.getQueryResults(getParentQueryResultsID((SubqueryLocator)(queryDefn.getSourceQuery())));
      IQueryDefinition queryDefinition=queryResults.getPreparedQuery().getReportQueryDefn();
      if (queryDefn.getSourceQuery() instanceof SubqueryLocator) {
        ArrayList<IBinding> bindingList=new ArrayList<IBinding>();
        getSubQueryBindings(queryDefinition,((SubqueryLocator)queryDefn.getSourceQuery()).getName(),bindingList);
        addQueryBindings(bindingList,queryDefinition.getBindings().values());
        bindings=bindingList.toArray(new IBinding[0]);
      }
 else {
        bindings=(IBinding[])(queryDefinition.getBindings().values().toArray(new IBinding[0]));
      }
    }
 else {
      this.queryResults=PreparedQueryUtil.newInstance(dataEngine,(IQueryDefinition)queryDefn.getSourceQuery(),null).execute(null);
      if (queryResults != null && queryResults.getPreparedQuery() != null) {
        IQueryDefinition queryDefinition=queryResults.getPreparedQuery().getReportQueryDefn();
        bindings=(IBinding[])queryDefinition.getBindings().values().toArray(new IBinding[0]);
      }
 else {
        bindings=new IBinding[0];
      }
    }
    for (int i=0; i < bindings.length; i++) {
      IBinding binding=bindings[i];
      this.queryDefn.addBinding(new Binding(binding.getBindingName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(binding.getBindingName()),binding.getDataType())));
    }
  }
 catch (  BirtException e) {
    throw DataException.wrap(e);
  }
}

Fixed version (ground truth):
protected void prepareQuery() throws DataException {
  try {
    IBinding[] bindings=null;
    if (this.queryDefn.getSourceQuery() instanceof SubqueryLocator) {
      this.queryResults=engine.getQueryResults(getParentQueryResultsID((SubqueryLocator)(queryDefn.getSourceQuery())));
      IQueryDefinition queryDefinition=queryResults.getPreparedQuery().getReportQueryDefn();
      if (queryDefn.getSourceQuery() instanceof SubqueryLocator) {
        ArrayList<IBinding> bindingList=new ArrayList<IBinding>();
        getSubQueryBindings(queryDefinition,((SubqueryLocator)queryDefn.getSourceQuery()).getName(),bindingList);
        addQueryBindings(bindingList,queryDefinition.getBindings().values());
        bindings=bindingList.toArray(new IBinding[0]);
      }
 else {
        bindings=(IBinding[])(queryDefinition.getBindings().values().toArray(new IBinding[0]));
      }
    }
 else {
      this.queryResults=PreparedQueryUtil.newInstance(dataEngine,(IQueryDefinition)queryDefn.getSourceQuery(),null).execute(null);
      if (queryResults != null && queryResults.getPreparedQuery() != null) {
        IQueryDefinition queryDefinition=queryResults.getPreparedQuery().getReportQueryDefn();
        bindings=(IBinding[])queryDefinition.getBindings().values().toArray(new IBinding[0]);
      }
 else {
        bindings=new IBinding[0];
      }
    }
    for (int i=0; i < bindings.length; i++) {
      IBinding binding=bindings[i];
      if (!this.queryDefn.getBindings().containsKey(binding.getBindingName()))       this.queryDefn.addBinding(new Binding(binding.getBindingName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(binding.getBindingName()),binding.getDataType())));
    }
  }
 catch (  BirtException e) {
    throw DataException.wrap(e);
  }
}