Program: 191583
Project: 191583
Buggy source:
/** 
 * @hide 
 */
public void writeToParcel(Parcel out,long now,int flags){
  out.writeInt(MAGIC);
  out.writeInt(PARCEL_VERSION);
  out.writeInt(STATE_COUNT);
  out.writeInt(ADJ_COUNT);
  out.writeInt(PSS_COUNT);
  out.writeInt(SYS_MEM_USAGE_COUNT);
  out.writeInt(SparseMappingTable.ARRAY_SIZE);
  mCommonStringToIndex=new ArrayMap<String,Integer>(mProcesses.size());
  ArrayMap<String,SparseArray<ProcessState>> procMap=mProcesses.getMap();
  final int NPROC=procMap.size();
  for (int ip=0; ip < NPROC; ip++) {
    SparseArray<ProcessState> uids=procMap.valueAt(ip);
    final int NUID=uids.size();
    for (int iu=0; iu < NUID; iu++) {
      uids.valueAt(iu).commitStateTime(now);
    }
  }
  final ArrayMap<String,SparseArray<SparseArray<PackageState>>> pkgMap=mPackages.getMap();
  final int NPKG=pkgMap.size();
  for (int ip=0; ip < NPKG; ip++) {
    final SparseArray<SparseArray<PackageState>> uids=pkgMap.valueAt(ip);
    final int NUID=uids.size();
    for (int iu=0; iu < NUID; iu++) {
      final SparseArray<PackageState> vpkgs=uids.valueAt(iu);
      final int NVERS=vpkgs.size();
      for (int iv=0; iv < NVERS; iv++) {
        PackageState pkgState=vpkgs.valueAt(iv);
        final int NPROCS=pkgState.mProcesses.size();
        for (int iproc=0; iproc < NPROCS; iproc++) {
          ProcessState proc=pkgState.mProcesses.valueAt(iproc);
          if (proc.getCommonProcess() != proc) {
            proc.commitStateTime(now);
          }
        }
        final int NSRVS=pkgState.mServices.size();
        for (int isvc=0; isvc < NSRVS; isvc++) {
          pkgState.mServices.valueAt(isvc).commitStateTime(now);
        }
      }
    }
  }
  out.writeLong(mTimePeriodStartClock);
  out.writeLong(mTimePeriodStartRealtime);
  out.writeLong(mTimePeriodEndRealtime);
  out.writeLong(mTimePeriodStartUptime);
  out.writeLong(mTimePeriodEndUptime);
  out.writeString(mRuntime);
  out.writeInt(mFlags);
  mTableData.writeToParcel(out);
  if (mMemFactor != STATE_NOTHING) {
    mMemFactorDurations[mMemFactor]+=now - mStartTime;
    mStartTime=now;
  }
  writeCompactedLongArray(out,mMemFactorDurations,mMemFactorDurations.length);
  mSysMemUsage.writeToParcel(out);
  out.writeInt(NPROC);
  for (int ip=0; ip < NPROC; ip++) {
    writeCommonString(out,procMap.keyAt(ip));
    final SparseArray<ProcessState> uids=procMap.valueAt(ip);
    final int NUID=uids.size();
    out.writeInt(NUID);
    for (int iu=0; iu < NUID; iu++) {
      out.writeInt(uids.keyAt(iu));
      final ProcessState proc=uids.valueAt(iu);
      writeCommonString(out,proc.getPackage());
      out.writeInt(proc.getVersion());
      proc.writeToParcel(out,now);
    }
  }
  out.writeInt(NPKG);
  for (int ip=0; ip < NPKG; ip++) {
    writeCommonString(out,pkgMap.keyAt(ip));
    final SparseArray<SparseArray<PackageState>> uids=pkgMap.valueAt(ip);
    final int NUID=uids.size();
    out.writeInt(NUID);
    for (int iu=0; iu < NUID; iu++) {
      out.writeInt(uids.keyAt(iu));
      final SparseArray<PackageState> vpkgs=uids.valueAt(iu);
      final int NVERS=vpkgs.size();
      out.writeInt(NVERS);
      for (int iv=0; iv < NVERS; iv++) {
        out.writeInt(vpkgs.keyAt(iv));
        final PackageState pkgState=vpkgs.valueAt(iv);
        final int NPROCS=pkgState.mProcesses.size();
        out.writeInt(NPROCS);
        for (int iproc=0; iproc < NPROCS; iproc++) {
          writeCommonString(out,pkgState.mProcesses.keyAt(iproc));
          final ProcessState proc=pkgState.mProcesses.valueAt(iproc);
          if (proc.getCommonProcess() == proc) {
            out.writeInt(0);
          }
 else {
            out.writeInt(1);
            proc.writeToParcel(out,now);
          }
        }
        final int NSRVS=pkgState.mServices.size();
        out.writeInt(NSRVS);
        for (int isvc=0; isvc < NSRVS; isvc++) {
          out.writeString(pkgState.mServices.keyAt(isvc));
          final ServiceState svc=pkgState.mServices.valueAt(isvc);
          writeCommonString(out,svc.getProcessName());
          svc.writeToParcel(out,now);
        }
      }
    }
  }
  mCommonStringToIndex=null;
}

Fixed version (ground truth):
/** 
 * @hide 
 */
public void writeToParcel(Parcel out,long now,int flags){
  out.writeInt(MAGIC);
  out.writeInt(PARCEL_VERSION);
  out.writeInt(STATE_COUNT);
  out.writeInt(ADJ_COUNT);
  out.writeInt(PSS_COUNT);
  out.writeInt(SYS_MEM_USAGE_COUNT);
  out.writeInt(SparseMappingTable.ARRAY_SIZE);
  mCommonStringToIndex=new ArrayMap<String,Integer>(mProcesses.size());
  ArrayMap<String,SparseArray<ProcessState>> procMap=mProcesses.getMap();
  final int NPROC=procMap.size();
  for (int ip=0; ip < NPROC; ip++) {
    SparseArray<ProcessState> uids=procMap.valueAt(ip);
    final int NUID=uids.size();
    for (int iu=0; iu < NUID; iu++) {
      uids.valueAt(iu).commitStateTime(now);
    }
  }
  final ArrayMap<String,SparseArray<SparseArray<PackageState>>> pkgMap=mPackages.getMap();
  final int NPKG=pkgMap.size();
  for (int ip=0; ip < NPKG; ip++) {
    final SparseArray<SparseArray<PackageState>> uids=pkgMap.valueAt(ip);
    final int NUID=uids.size();
    for (int iu=0; iu < NUID; iu++) {
      final SparseArray<PackageState> vpkgs=uids.valueAt(iu);
      final int NVERS=vpkgs.size();
      for (int iv=0; iv < NVERS; iv++) {
        PackageState pkgState=vpkgs.valueAt(iv);
        final int NPROCS=pkgState.mProcesses.size();
        for (int iproc=0; iproc < NPROCS; iproc++) {
          ProcessState proc=pkgState.mProcesses.valueAt(iproc);
          if (proc.getCommonProcess() != proc) {
            proc.commitStateTime(now);
          }
        }
        final int NSRVS=pkgState.mServices.size();
        for (int isvc=0; isvc < NSRVS; isvc++) {
          pkgState.mServices.valueAt(isvc).commitStateTime(now);
        }
      }
    }
  }
  out.writeLong(mTimePeriodStartClock);
  out.writeLong(mTimePeriodStartRealtime);
  out.writeLong(mTimePeriodEndRealtime);
  out.writeLong(mTimePeriodStartUptime);
  out.writeLong(mTimePeriodEndUptime);
  out.writeString(mRuntime);
  out.writeInt(mHasSwappedOutPss ? 1 : 0);
  out.writeInt(mFlags);
  mTableData.writeToParcel(out);
  if (mMemFactor != STATE_NOTHING) {
    mMemFactorDurations[mMemFactor]+=now - mStartTime;
    mStartTime=now;
  }
  writeCompactedLongArray(out,mMemFactorDurations,mMemFactorDurations.length);
  mSysMemUsage.writeToParcel(out);
  out.writeInt(NPROC);
  for (int ip=0; ip < NPROC; ip++) {
    writeCommonString(out,procMap.keyAt(ip));
    final SparseArray<ProcessState> uids=procMap.valueAt(ip);
    final int NUID=uids.size();
    out.writeInt(NUID);
    for (int iu=0; iu < NUID; iu++) {
      out.writeInt(uids.keyAt(iu));
      final ProcessState proc=uids.valueAt(iu);
      writeCommonString(out,proc.getPackage());
      out.writeInt(proc.getVersion());
      proc.writeToParcel(out,now);
    }
  }
  out.writeInt(NPKG);
  for (int ip=0; ip < NPKG; ip++) {
    writeCommonString(out,pkgMap.keyAt(ip));
    final SparseArray<SparseArray<PackageState>> uids=pkgMap.valueAt(ip);
    final int NUID=uids.size();
    out.writeInt(NUID);
    for (int iu=0; iu < NUID; iu++) {
      out.writeInt(uids.keyAt(iu));
      final SparseArray<PackageState> vpkgs=uids.valueAt(iu);
      final int NVERS=vpkgs.size();
      out.writeInt(NVERS);
      for (int iv=0; iv < NVERS; iv++) {
        out.writeInt(vpkgs.keyAt(iv));
        final PackageState pkgState=vpkgs.valueAt(iv);
        final int NPROCS=pkgState.mProcesses.size();
        out.writeInt(NPROCS);
        for (int iproc=0; iproc < NPROCS; iproc++) {
          writeCommonString(out,pkgState.mProcesses.keyAt(iproc));
          final ProcessState proc=pkgState.mProcesses.valueAt(iproc);
          if (proc.getCommonProcess() == proc) {
            out.writeInt(0);
          }
 else {
            out.writeInt(1);
            proc.writeToParcel(out,now);
          }
        }
        final int NSRVS=pkgState.mServices.size();
        out.writeInt(NSRVS);
        for (int isvc=0; isvc < NSRVS; isvc++) {
          out.writeString(pkgState.mServices.keyAt(isvc));
          final ServiceState svc=pkgState.mServices.valueAt(isvc);
          writeCommonString(out,svc.getProcessName());
          svc.writeToParcel(out,now);
        }
      }
    }
  }
  mCommonStringToIndex=null;
}