Program: 66083
Project: 66083
Buggy source:
/** 
 * @param dos
 * @param binding
 * @throws DataException
 */
public static void saveBinding(DataOutputStream dos,IBinding binding) throws DataException {
  int type=binding.getDataType();
  String name=binding.getBindingName();
  String function=binding.getAggrFunction();
  IBaseExpression expr=binding.getExpression();
  IBaseExpression filter=binding.getFilter();
  List arguments=binding.getArguments();
  List aggregateOn=binding.getAggregatOns();
  ITimeFunction timeFunction=binding.getTimeFunction();
  try {
    IOUtil.writeInt(dos,type);
    IOUtil.writeString(dos,name);
    IOUtil.writeString(dos,function);
    ExprUtil.saveBaseExpr(dos,expr);
    ExprUtil.saveBaseExpr(dos,filter);
    IOUtil.writeInt(dos,arguments.size());
    for (int i=0; i < arguments.size(); i++) {
      ExprUtil.saveBaseExpr(dos,(IBaseExpression)arguments.get(i));
    }
    IOUtil.writeInt(dos,aggregateOn.size());
    for (int i=0; i < aggregateOn.size(); i++) {
      IOUtil.writeString(dos,aggregateOn.get(i).toString());
    }
    if (VersionManager.getLatestVersion() >= VersionManager.VERSION_2_6_3_1) {
      if (timeFunction != null) {
        IOUtil.writeBool(dos,true);
        IOUtil.writeString(dos,timeFunction.getTimeDimension());
        IOUtil.writeObject(dos,timeFunction.getReferenceDate().getDate());
        ITimePeriod baseTimePeriod=timeFunction.getBaseTimePeriod();
        ITimePeriod relativeTimePeriod=timeFunction.getRelativeTimePeriod();
        if (baseTimePeriod != null) {
          IOUtil.writeBool(dos,true);
          IOUtil.writeString(dos,baseTimePeriod.getType().toString());
          IOUtil.writeInt(dos,baseTimePeriod.countOfUnit());
          IOUtil.writeBool(dos,baseTimePeriod.isCurrent());
        }
 else {
          IOUtil.writeBool(dos,false);
        }
        if (relativeTimePeriod != null) {
          IOUtil.writeBool(dos,true);
          IOUtil.writeObject(dos,relativeTimePeriod.getType().toString());
          IOUtil.writeInt(dos,relativeTimePeriod.countOfUnit());
        }
 else {
          IOUtil.writeBool(dos,false);
        }
      }
 else {
        IOUtil.writeBool(dos,false);
      }
    }
  }
 catch (  IOException e) {
    throw new DataException(e.getLocalizedMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * @param dos
 * @param binding
 * @throws DataException
 */
public static void saveBinding(DataOutputStream dos,IBinding binding,int version) throws DataException {
  int type=binding.getDataType();
  String name=binding.getBindingName();
  String function=binding.getAggrFunction();
  IBaseExpression expr=binding.getExpression();
  IBaseExpression filter=binding.getFilter();
  List arguments=binding.getArguments();
  List aggregateOn=binding.getAggregatOns();
  ITimeFunction timeFunction=binding.getTimeFunction();
  try {
    IOUtil.writeInt(dos,type);
    IOUtil.writeString(dos,name);
    IOUtil.writeString(dos,function);
    ExprUtil.saveBaseExpr(dos,expr);
    ExprUtil.saveBaseExpr(dos,filter);
    IOUtil.writeInt(dos,arguments.size());
    for (int i=0; i < arguments.size(); i++) {
      ExprUtil.saveBaseExpr(dos,(IBaseExpression)arguments.get(i));
    }
    IOUtil.writeInt(dos,aggregateOn.size());
    for (int i=0; i < aggregateOn.size(); i++) {
      IOUtil.writeString(dos,aggregateOn.get(i).toString());
    }
    if (version >= VersionManager.VERSION_2_6_3_1) {
      if (timeFunction != null) {
        IOUtil.writeBool(dos,true);
        IOUtil.writeString(dos,timeFunction.getTimeDimension());
        IOUtil.writeObject(dos,timeFunction.getReferenceDate().getDate());
        ITimePeriod baseTimePeriod=timeFunction.getBaseTimePeriod();
        ITimePeriod relativeTimePeriod=timeFunction.getRelativeTimePeriod();
        if (baseTimePeriod != null) {
          IOUtil.writeBool(dos,true);
          IOUtil.writeString(dos,baseTimePeriod.getType().toString());
          IOUtil.writeInt(dos,baseTimePeriod.countOfUnit());
          IOUtil.writeBool(dos,baseTimePeriod.isCurrent());
        }
 else {
          IOUtil.writeBool(dos,false);
        }
        if (relativeTimePeriod != null) {
          IOUtil.writeBool(dos,true);
          IOUtil.writeObject(dos,relativeTimePeriod.getType().toString());
          IOUtil.writeInt(dos,relativeTimePeriod.countOfUnit());
        }
 else {
          IOUtil.writeBool(dos,false);
        }
      }
 else {
        IOUtil.writeBool(dos,false);
      }
    }
  }
 catch (  IOException e) {
    throw new DataException(e.getLocalizedMessage(),e);
  }
}