Program: 21697
Project: 21697
Buggy source:
private void listenToSocket() throws IOException {
  LocalSocket socket=null;
  try {
    socket=new LocalSocket();
    LocalSocketAddress address=new LocalSocketAddress(mSocket,LocalSocketAddress.Namespace.RESERVED);
    socket.connect(address);
    mCallbacks.onDaemonConnected();
    InputStream inputStream=socket.getInputStream();
    mOutputStream=socket.getOutputStream();
    byte[] buffer=new byte[BUFFER_SIZE];
    int start=0;
    while (true) {
      int count=inputStream.read(buffer,start,BUFFER_SIZE - start);
      if (count < 0)       break;
      count+=start;
      start=0;
      for (int i=0; i < count; i++) {
        if (buffer[i] == 0) {
          String event=new String(buffer,start,i - start);
          if (LOCAL_LOGD)           Slog.d(TAG,String.format("String_Node_Str",event));
          String[] tokens=event.split("String_Node_Str");
          try {
            int code=Integer.parseInt(tokens[0]);
            if (code >= ResponseCode.UnsolicitedInformational) {
              try {
                if (!mCallbacks.onEvent(code,event,tokens)) {
                  Slog.w(TAG,String.format("String_Node_Str",event));
                }
              }
 catch (              Exception ex) {
                Slog.e(TAG,String.format("String_Node_Str",event),ex);
              }
            }
 else {
              try {
                mResponseQueue.put(event);
              }
 catch (              InterruptedException ex) {
                Slog.e(TAG,"String_Node_Str",ex);
              }
            }
          }
 catch (          NumberFormatException nfe) {
            Slog.w(TAG,String.format("String_Node_Str",event));
          }
          start=i + 1;
        }
      }
      if (start != count) {
        final int remaining=BUFFER_SIZE - start;
        System.arraycopy(buffer,start,buffer,0,remaining);
        start=remaining;
      }
 else {
        start=0;
      }
    }
  }
 catch (  IOException ex) {
    Slog.e(TAG,"String_Node_Str",ex);
    throw ex;
  }
 finally {
synchronized (this) {
      if (mOutputStream != null) {
        try {
          mOutputStream.close();
        }
 catch (        IOException e) {
          Slog.w(TAG,"String_Node_Str",e);
        }
        mOutputStream=null;
      }
    }
    try {
      if (socket != null) {
        socket.close();
      }
    }
 catch (    IOException ex) {
      Slog.w(TAG,"String_Node_Str",ex);
    }
  }
}

Fixed version (ground truth):
private void listenToSocket() throws IOException {
  LocalSocket socket=null;
  try {
    socket=new LocalSocket();
    LocalSocketAddress address=new LocalSocketAddress(mSocket,LocalSocketAddress.Namespace.RESERVED);
    socket.connect(address);
    mOutputStream=socket.getOutputStream();
    mCallbacks.onDaemonConnected();
    InputStream inputStream=socket.getInputStream();
    byte[] buffer=new byte[BUFFER_SIZE];
    int start=0;
    while (true) {
      int count=inputStream.read(buffer,start,BUFFER_SIZE - start);
      if (count < 0)       break;
      count+=start;
      start=0;
      for (int i=0; i < count; i++) {
        if (buffer[i] == 0) {
          String event=new String(buffer,start,i - start);
          if (LOCAL_LOGD)           Slog.d(TAG,String.format("String_Node_Str",event));
          String[] tokens=event.split("String_Node_Str");
          try {
            int code=Integer.parseInt(tokens[0]);
            if (code >= ResponseCode.UnsolicitedInformational) {
              try {
                if (!mCallbacks.onEvent(code,event,tokens)) {
                  Slog.w(TAG,String.format("String_Node_Str",event));
                }
              }
 catch (              Exception ex) {
                Slog.e(TAG,String.format("String_Node_Str",event),ex);
              }
            }
 else {
              try {
                mResponseQueue.put(event);
              }
 catch (              InterruptedException ex) {
                Slog.e(TAG,"String_Node_Str",ex);
              }
            }
          }
 catch (          NumberFormatException nfe) {
            Slog.w(TAG,String.format("String_Node_Str",event));
          }
          start=i + 1;
        }
      }
      if (start != count) {
        final int remaining=BUFFER_SIZE - start;
        System.arraycopy(buffer,start,buffer,0,remaining);
        start=remaining;
      }
 else {
        start=0;
      }
    }
  }
 catch (  IOException ex) {
    Slog.e(TAG,"String_Node_Str",ex);
    throw ex;
  }
 finally {
synchronized (this) {
      if (mOutputStream != null) {
        try {
          mOutputStream.close();
        }
 catch (        IOException e) {
          Slog.w(TAG,"String_Node_Str",e);
        }
        mOutputStream=null;
      }
    }
    try {
      if (socket != null) {
        socket.close();
      }
    }
 catch (    IOException ex) {
      Slog.w(TAG,"String_Node_Str",ex);
    }
  }
}