Program: 192742
Project: 192742
Buggy source:
protected byte[] getBackupPayload(String key){
synchronized (mLock) {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    if (KEY_USAGE_STATS.equals(key)) {
      prune(System.currentTimeMillis());
      DataOutputStream out=new DataOutputStream(baos);
      try {
        out.writeInt(BACKUP_STATE_VERSION);
        out.writeInt(mSortedStatFiles[UsageStatsManager.INTERVAL_DAILY].size());
        for (int i=0; i < mSortedStatFiles[UsageStatsManager.INTERVAL_DAILY].size(); i++) {
          writeIntervalStatsToStream(out,mSortedStatFiles[UsageStatsManager.INTERVAL_DAILY].valueAt(i));
        }
        out.writeInt(mSortedStatFiles[UsageStatsManager.INTERVAL_WEEKLY].size());
        for (int i=0; i < mSortedStatFiles[UsageStatsManager.INTERVAL_WEEKLY].size(); i++) {
          writeIntervalStatsToStream(out,mSortedStatFiles[UsageStatsManager.INTERVAL_WEEKLY].valueAt(i));
        }
        out.writeInt(mSortedStatFiles[UsageStatsManager.INTERVAL_MONTHLY].size());
        for (int i=0; i < mSortedStatFiles[UsageStatsManager.INTERVAL_MONTHLY].size(); i++) {
          writeIntervalStatsToStream(out,mSortedStatFiles[UsageStatsManager.INTERVAL_MONTHLY].valueAt(i));
        }
        out.writeInt(mSortedStatFiles[UsageStatsManager.INTERVAL_YEARLY].size());
        for (int i=0; i < mSortedStatFiles[UsageStatsManager.INTERVAL_YEARLY].size(); i++) {
          writeIntervalStatsToStream(out,mSortedStatFiles[UsageStatsManager.INTERVAL_YEARLY].valueAt(i));
        }
        if (DEBUG)         Slog.i(TAG,"String_Node_Str" + baos.size() + "String_Node_Str");
      }
 catch (      IOException ioe) {
        Slog.d(TAG,"String_Node_Str",ioe);
        baos.reset();
      }
    }
    return baos.toByteArray();
  }
}

Fixed version (ground truth):
byte[] getBackupPayload(String key){
synchronized (mLock) {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    if (KEY_USAGE_STATS.equals(key)) {
      prune(System.currentTimeMillis());
      DataOutputStream out=new DataOutputStream(baos);
      try {
        out.writeInt(BACKUP_VERSION);
        out.writeInt(mSortedStatFiles[UsageStatsManager.INTERVAL_DAILY].size());
        for (int i=0; i < mSortedStatFiles[UsageStatsManager.INTERVAL_DAILY].size(); i++) {
          writeIntervalStatsToStream(out,mSortedStatFiles[UsageStatsManager.INTERVAL_DAILY].valueAt(i));
        }
        out.writeInt(mSortedStatFiles[UsageStatsManager.INTERVAL_WEEKLY].size());
        for (int i=0; i < mSortedStatFiles[UsageStatsManager.INTERVAL_WEEKLY].size(); i++) {
          writeIntervalStatsToStream(out,mSortedStatFiles[UsageStatsManager.INTERVAL_WEEKLY].valueAt(i));
        }
        out.writeInt(mSortedStatFiles[UsageStatsManager.INTERVAL_MONTHLY].size());
        for (int i=0; i < mSortedStatFiles[UsageStatsManager.INTERVAL_MONTHLY].size(); i++) {
          writeIntervalStatsToStream(out,mSortedStatFiles[UsageStatsManager.INTERVAL_MONTHLY].valueAt(i));
        }
        out.writeInt(mSortedStatFiles[UsageStatsManager.INTERVAL_YEARLY].size());
        for (int i=0; i < mSortedStatFiles[UsageStatsManager.INTERVAL_YEARLY].size(); i++) {
          writeIntervalStatsToStream(out,mSortedStatFiles[UsageStatsManager.INTERVAL_YEARLY].valueAt(i));
        }
        if (DEBUG)         Slog.i(TAG,"String_Node_Str" + baos.size() + "String_Node_Str");
      }
 catch (      IOException ioe) {
        Slog.d(TAG,"String_Node_Str",ioe);
        baos.reset();
      }
    }
    return baos.toByteArray();
  }
}