Program: 199880
Project: 199880
Buggy source:
/** 
 * Reads one start command from the command socket. If successful, a child is forked and a   {@link ZygoteInit.MethodAndArgsCaller}exception is thrown in that child while in the parent process, the method returns normally. On failure, the child is not spawned and messages are printed to the log and stderr. Returns a boolean status value indicating whether an end-of-file on the command socket has been encountered.
 * @return false if command socket should continue to be read from, ortrue if an end-of-file has been encountered.
 * @throws ZygoteInit.MethodAndArgsCaller trampoline to invoke main()method in child process
 */
boolean runOnce() throws ZygoteInit.MethodAndArgsCaller {
  String args[];
  Arguments parsedArgs=null;
  FileDescriptor[] descriptors;
  try {
    args=readArgumentList();
    descriptors=mSocket.getAncillaryFileDescriptors();
  }
 catch (  IOException ex) {
    Log.w(TAG,"String_Node_Str" + ex.getMessage());
    closeSocket();
    return true;
  }
  if (args == null) {
    closeSocket();
    return true;
  }
  PrintStream newStderr=null;
  if (descriptors != null && descriptors.length >= 3) {
    newStderr=new PrintStream(new FileOutputStream(descriptors[2]));
  }
  int pid=-1;
  FileDescriptor childPipeFd=null;
  FileDescriptor serverPipeFd=null;
  try {
    parsedArgs=new Arguments(args);
    if (parsedArgs.permittedCapabilities != 0 || parsedArgs.effectiveCapabilities != 0) {
      throw new ZygoteSecurityException("String_Node_Str" + "String_Node_Str" + Long.toHexString(parsedArgs.permittedCapabilities) + "String_Node_Str"+ Long.toHexString(parsedArgs.effectiveCapabilities));
    }
    applyUidSecurityPolicy(parsedArgs,peer,peerSecurityContext);
    applyRlimitSecurityPolicy(parsedArgs,peer,peerSecurityContext);
    applyInvokeWithSecurityPolicy(parsedArgs,peer,peerSecurityContext);
    applyseInfoSecurityPolicy(parsedArgs,peer,peerSecurityContext);
    applyDebuggerSystemProperty(parsedArgs);
    applyInvokeWithSystemProperty(parsedArgs);
    int[][] rlimits=null;
    if (parsedArgs.rlimits != null) {
      rlimits=parsedArgs.rlimits.toArray(intArray2d);
    }
    if (parsedArgs.runtimeInit && parsedArgs.invokeWith != null) {
      FileDescriptor[] pipeFds=Libcore.os.pipe();
      childPipeFd=pipeFds[1];
      serverPipeFd=pipeFds[0];
      ZygoteInit.setCloseOnExec(serverPipeFd,true);
    }
    pid=Zygote.forkAndSpecialize(parsedArgs.uid,parsedArgs.gid,parsedArgs.gids,parsedArgs.debugFlags,rlimits,parsedArgs.mountExternal,parsedArgs.seInfo,parsedArgs.niceName);
  }
 catch (  IOException ex) {
    logAndPrintError(newStderr,"String_Node_Str",ex);
  }
catch (  ErrnoException ex) {
    logAndPrintError(newStderr,"String_Node_Str",ex);
  }
catch (  IllegalArgumentException ex) {
    logAndPrintError(newStderr,"String_Node_Str",ex);
  }
catch (  ZygoteSecurityException ex) {
    logAndPrintError(newStderr,"String_Node_Str",ex);
  }
  try {
    if (pid == 0) {
      IoUtils.closeQuietly(serverPipeFd);
      serverPipeFd=null;
      handleChildProc(parsedArgs,descriptors,childPipeFd,newStderr);
      return true;
    }
 else {
      IoUtils.closeQuietly(childPipeFd);
      childPipeFd=null;
      return handleParentProc(pid,descriptors,serverPipeFd,parsedArgs);
    }
  }
  finally {
    IoUtils.closeQuietly(childPipeFd);
    IoUtils.closeQuietly(serverPipeFd);
  }
}

Fixed version (ground truth):
/** 
 * Reads one start command from the command socket. If successful, a child is forked and a   {@link ZygoteInit.MethodAndArgsCaller}exception is thrown in that child while in the parent process, the method returns normally. On failure, the child is not spawned and messages are printed to the log and stderr. Returns a boolean status value indicating whether an end-of-file on the command socket has been encountered.
 * @return false if command socket should continue to be read from, ortrue if an end-of-file has been encountered.
 * @throws ZygoteInit.MethodAndArgsCaller trampoline to invoke main()method in child process
 */
boolean runOnce() throws ZygoteInit.MethodAndArgsCaller {
  String args[];
  Arguments parsedArgs=null;
  FileDescriptor[] descriptors;
  try {
    args=readArgumentList();
    descriptors=mSocket.getAncillaryFileDescriptors();
  }
 catch (  IOException ex) {
    Log.w(TAG,"String_Node_Str" + ex.getMessage());
    closeSocket();
    return true;
  }
  if (args == null) {
    closeSocket();
    return true;
  }
  PrintStream newStderr=null;
  if (descriptors != null && descriptors.length >= 3) {
    newStderr=new PrintStream(new FileOutputStream(descriptors[2]));
  }
  int pid=-1;
  FileDescriptor childPipeFd=null;
  FileDescriptor serverPipeFd=null;
  try {
    parsedArgs=new Arguments(args);
    if (parsedArgs.permittedCapabilities != 0 || parsedArgs.effectiveCapabilities != 0) {
      throw new ZygoteSecurityException("String_Node_Str" + "String_Node_Str" + Long.toHexString(parsedArgs.permittedCapabilities) + "String_Node_Str"+ Long.toHexString(parsedArgs.effectiveCapabilities));
    }
    applyUidSecurityPolicy(parsedArgs,peer,peerSecurityContext);
    applyRlimitSecurityPolicy(parsedArgs,peer,peerSecurityContext);
    applyInvokeWithSecurityPolicy(parsedArgs,peer,peerSecurityContext);
    applyseInfoSecurityPolicy(parsedArgs,peer,peerSecurityContext);
    applyDebuggerSystemProperty(parsedArgs);
    applyInvokeWithSystemProperty(parsedArgs);
    int[][] rlimits=null;
    if (parsedArgs.rlimits != null) {
      rlimits=parsedArgs.rlimits.toArray(intArray2d);
    }
    if (parsedArgs.runtimeInit && parsedArgs.invokeWith != null) {
      FileDescriptor[] pipeFds=Libcore.os.pipe();
      childPipeFd=pipeFds[1];
      serverPipeFd=pipeFds[0];
      ZygoteInit.setCloseOnExec(serverPipeFd,true);
    }
    int[] fdsToClose={-1,-1};
    FileDescriptor fd=mSocket.getFileDescriptor();
    if (fd != null) {
      fdsToClose[0]=fd.getInt$();
    }
    fd=ZygoteInit.getServerSocketFileDescriptor();
    if (fd != null) {
      fdsToClose[1]=fd.getInt$();
    }
    fd=null;
    pid=Zygote.forkAndSpecialize(parsedArgs.uid,parsedArgs.gid,parsedArgs.gids,parsedArgs.debugFlags,rlimits,parsedArgs.mountExternal,parsedArgs.seInfo,parsedArgs.niceName,fdsToClose);
  }
 catch (  IOException ex) {
    logAndPrintError(newStderr,"String_Node_Str",ex);
  }
catch (  ErrnoException ex) {
    logAndPrintError(newStderr,"String_Node_Str",ex);
  }
catch (  IllegalArgumentException ex) {
    logAndPrintError(newStderr,"String_Node_Str",ex);
  }
catch (  ZygoteSecurityException ex) {
    logAndPrintError(newStderr,"String_Node_Str",ex);
  }
  try {
    if (pid == 0) {
      IoUtils.closeQuietly(serverPipeFd);
      serverPipeFd=null;
      handleChildProc(parsedArgs,descriptors,childPipeFd,newStderr);
      return true;
    }
 else {
      IoUtils.closeQuietly(childPipeFd);
      childPipeFd=null;
      return handleParentProc(pid,descriptors,serverPipeFd,parsedArgs);
    }
  }
  finally {
    IoUtils.closeQuietly(childPipeFd);
    IoUtils.closeQuietly(serverPipeFd);
  }
}