Program: 882
Project: 882
Buggy source:
@Override protected void dump(FileDescriptor fd,PrintWriter pw,String[] args){
  if (mAm.checkCallingPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
    pw.println("String_Node_Str" + Binder.getCallingPid() + "String_Node_Str"+ Binder.getCallingUid()+ "String_Node_Str"+ android.Manifest.permission.DUMP);
    return;
  }
  final long now=SystemClock.uptimeMillis();
  boolean isCheckin=false;
  boolean isCompact=false;
  boolean isCsv=false;
  boolean currentOnly=false;
  boolean dumpDetails=false;
  boolean dumpFullDetails=false;
  boolean dumpAll=false;
  int aggregateHours=0;
  boolean activeOnly=false;
  String reqPackage=null;
  boolean csvSepScreenStats=false;
  int[] csvScreenStats=new int[]{ProcessStats.ADJ_SCREEN_OFF,ProcessStats.ADJ_SCREEN_ON};
  boolean csvSepMemStats=false;
  int[] csvMemStats=new int[]{ProcessStats.ADJ_MEM_FACTOR_CRITICAL};
  boolean csvSepProcStats=true;
  int[] csvProcStats=ProcessStats.ALL_PROC_STATES;
  if (args != null) {
    for (int i=0; i < args.length; i++) {
      String arg=args[i];
      if ("String_Node_Str".equals(arg)) {
        isCheckin=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        isCompact=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        isCsv=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        i++;
        if (i >= args.length) {
          pw.println("String_Node_Str");
          dumpHelp(pw);
          return;
        }
        boolean[] sep=new boolean[1];
        String[] error=new String[1];
        csvScreenStats=parseStateList(ProcessStats.ADJ_SCREEN_NAMES_CSV,ProcessStats.ADJ_SCREEN_MOD,args[i],sep,error);
        if (csvScreenStats == null) {
          pw.println("String_Node_Str" + args[i] + "String_Node_Str"+ error[0]);
          dumpHelp(pw);
          return;
        }
        csvSepScreenStats=sep[0];
      }
 else       if ("String_Node_Str".equals(arg)) {
        i++;
        if (i >= args.length) {
          pw.println("String_Node_Str");
          dumpHelp(pw);
          return;
        }
        boolean[] sep=new boolean[1];
        String[] error=new String[1];
        csvMemStats=parseStateList(ProcessStats.ADJ_MEM_NAMES_CSV,1,args[i],sep,error);
        if (csvMemStats == null) {
          pw.println("String_Node_Str" + args[i] + "String_Node_Str"+ error[0]);
          dumpHelp(pw);
          return;
        }
        csvSepMemStats=sep[0];
      }
 else       if ("String_Node_Str".equals(arg)) {
        i++;
        if (i >= args.length) {
          pw.println("String_Node_Str");
          dumpHelp(pw);
          return;
        }
        boolean[] sep=new boolean[1];
        String[] error=new String[1];
        csvProcStats=parseStateList(ProcessStats.STATE_NAMES_CSV,1,args[i],sep,error);
        if (csvProcStats == null) {
          pw.println("String_Node_Str" + args[i] + "String_Node_Str"+ error[0]);
          dumpHelp(pw);
          return;
        }
        csvSepProcStats=sep[0];
      }
 else       if ("String_Node_Str".equals(arg)) {
        dumpDetails=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        dumpFullDetails=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        i++;
        if (i >= args.length) {
          pw.println("String_Node_Str");
          dumpHelp(pw);
          return;
        }
        try {
          aggregateHours=Integer.parseInt(args[i]);
        }
 catch (        NumberFormatException e) {
          pw.println("String_Node_Str" + args[i]);
          dumpHelp(pw);
          return;
        }
      }
 else       if ("String_Node_Str".equals(arg)) {
        activeOnly=true;
        currentOnly=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        currentOnly=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mAm) {
          mProcessStats.mFlags|=ProcessStats.FLAG_COMPLETE;
          writeStateLocked(true,true);
          pw.println("String_Node_Str");
        }
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mAm) {
          mProcessStats.resetSafely();
          pw.println("String_Node_Str");
        }
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mAm) {
          mProcessStats.resetSafely();
          ArrayList<String> files=getCommittedFiles(0,true,true);
          if (files != null) {
            for (int fi=0; fi < files.size(); fi++) {
              (new File(files.get(fi))).delete();
            }
          }
          pw.println("String_Node_Str");
        }
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mAm) {
          writeStateSyncLocked();
          pw.println("String_Node_Str");
        }
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mAm) {
          readLocked(mProcessStats,mFile);
          pw.println("String_Node_Str");
        }
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
        dumpHelp(pw);
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
        dumpDetails=true;
        dumpAll=true;
      }
 else       if (arg.length() > 0 && arg.charAt(0) == '-') {
        pw.println("String_Node_Str" + arg);
        dumpHelp(pw);
        return;
      }
 else {
        try {
          IPackageManager pm=AppGlobals.getPackageManager();
          if (pm.getPackageUid(arg,UserHandle.getCallingUserId()) >= 0) {
            reqPackage=arg;
            dumpDetails=true;
          }
        }
 catch (        RemoteException e) {
        }
        if (reqPackage == null) {
          pw.println("String_Node_Str" + arg);
          dumpHelp(pw);
          return;
        }
      }
    }
  }
  if (isCsv) {
    pw.print("String_Node_Str");
    if (!csvSepScreenStats) {
      for (int i=0; i < csvScreenStats.length; i++) {
        pw.print("String_Node_Str");
        ProcessStats.printScreenLabelCsv(pw,csvScreenStats[i]);
      }
    }
    if (!csvSepMemStats) {
      for (int i=0; i < csvMemStats.length; i++) {
        pw.print("String_Node_Str");
        ProcessStats.printMemLabelCsv(pw,csvMemStats[i]);
      }
    }
    if (!csvSepProcStats) {
      for (int i=0; i < csvProcStats.length; i++) {
        pw.print("String_Node_Str");
        pw.print(ProcessStats.STATE_NAMES_CSV[csvProcStats[i]]);
      }
    }
    pw.println();
synchronized (mAm) {
      dumpFilteredProcessesCsvLocked(pw,null,csvSepScreenStats,csvScreenStats,csvSepMemStats,csvMemStats,csvSepProcStats,csvProcStats,now,reqPackage);
    }
    return;
  }
 else   if (aggregateHours != 0) {
    ParcelFileDescriptor pfd=getStatsOverTime(aggregateHours * 60 * 60* 1000 - (ProcessStats.COMMIT_PERIOD / 2));
    if (pfd == null) {
      pw.println("String_Node_Str");
      return;
    }
    ProcessStats stats=new ProcessStats(false);
    InputStream stream=new ParcelFileDescriptor.AutoCloseInputStream(pfd);
    stats.read(stream);
    if (stats.mReadError != null) {
      pw.print("String_Node_Str");
      pw.println(stats.mReadError);
      return;
    }
    if (isCompact) {
      stats.dumpCheckinLocked(pw,reqPackage);
    }
 else {
      if (dumpDetails || dumpFullDetails) {
        stats.dumpLocked(pw,reqPackage,now,!dumpFullDetails,dumpAll,activeOnly);
      }
 else {
        stats.dumpSummaryLocked(pw,reqPackage,now,activeOnly);
      }
    }
    return;
  }
  boolean sepNeeded=false;
  if (!currentOnly || isCheckin) {
    mWriteLock.lock();
    try {
      ArrayList<String> files=getCommittedFiles(0,false,!isCheckin);
      if (files != null) {
        for (int i=0; i < files.size(); i++) {
          if (DEBUG)           Slog.d(TAG,"String_Node_Str" + files.get(i));
          try {
            AtomicFile file=new AtomicFile(new File(files.get(i)));
            ProcessStats processStats=new ProcessStats(false);
            readLocked(processStats,file);
            if (processStats.mReadError != null) {
              if (isCheckin || isCompact)               pw.print("String_Node_Str");
              pw.print("String_Node_Str");
              pw.print(files.get(i));
              pw.print("String_Node_Str");
              pw.println(processStats.mReadError);
              if (DEBUG)               Slog.d(TAG,"String_Node_Str" + files.get(i));
              (new File(files.get(i))).delete();
              continue;
            }
            String fileStr=file.getBaseFile().getPath();
            boolean checkedIn=fileStr.endsWith(STATE_FILE_CHECKIN_SUFFIX);
            if (isCheckin || isCompact) {
              processStats.dumpCheckinLocked(pw,reqPackage);
            }
 else {
              if (sepNeeded) {
                pw.println();
              }
 else {
                sepNeeded=true;
              }
              pw.print("String_Node_Str");
              pw.print(processStats.mTimePeriodStartClockStr);
              if (checkedIn)               pw.print("String_Node_Str");
              pw.println("String_Node_Str");
              if (dumpFullDetails) {
                mProcessStats.dumpLocked(pw,reqPackage,now,false,false,activeOnly);
              }
 else {
                processStats.dumpSummaryLocked(pw,reqPackage,now,activeOnly);
              }
            }
            if (isCheckin) {
              file.getBaseFile().renameTo(new File(fileStr + STATE_FILE_CHECKIN_SUFFIX));
            }
          }
 catch (          Throwable e) {
            pw.print("String_Node_Str");
            pw.println(files.get(i));
            e.printStackTrace(pw);
          }
        }
      }
    }
  finally {
      mWriteLock.unlock();
    }
  }
  if (!isCheckin) {
synchronized (mAm) {
      if (isCompact) {
        mProcessStats.dumpCheckinLocked(pw,reqPackage);
      }
 else {
        if (sepNeeded) {
          pw.println();
          pw.println("String_Node_Str");
        }
        if (dumpDetails || dumpFullDetails) {
          mProcessStats.dumpLocked(pw,reqPackage,now,!dumpFullDetails,dumpAll,activeOnly);
          if (dumpAll) {
            pw.print("String_Node_Str");
            pw.println(mFile.getBaseFile());
          }
        }
 else {
          mProcessStats.dumpSummaryLocked(pw,reqPackage,now,activeOnly);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void dump(FileDescriptor fd,PrintWriter pw,String[] args){
  if (mAm.checkCallingPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
    pw.println("String_Node_Str" + Binder.getCallingPid() + "String_Node_Str"+ Binder.getCallingUid()+ "String_Node_Str"+ android.Manifest.permission.DUMP);
    return;
  }
  long ident=Binder.clearCallingIdentity();
  try {
    dumpInner(fd,pw,args);
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
}