Program: 26495
Project: 26495
Buggy source:
@Override public void run(Connection con){
  m_IO=con.getTerminalIO();
  PowerManager pm=(PowerManager)RemoteKeyboardService.self.getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock wakeLock=pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,TAG);
  wakeLock.acquire();
  Resources res=RemoteKeyboardService.self.getResources();
  RemoteKeyboardService.self.updateNotification(con.getConnectionData().getInetAddress());
  try {
    titleBar=new Titlebar(m_IO,"String_Node_Str");
    titleBar.setTitleText(res.getString(R.string.terminal_title));
    titleBar.setAlignment(Titlebar.ALIGN_LEFT);
    titleBar.setForegroundColor(ColorHelper.WHITE);
    titleBar.setBackgroundColor(ColorHelper.BLUE);
    content=new Label(m_IO,"String_Node_Str");
    content.setLocation(0,2);
    statusBar=new Statusbar(m_IO,"String_Node_Str");
    statusBar.setStatusText(res.getString(R.string.terminal_statusbar));
    statusBar.setAlignment(Titlebar.ALIGN_LEFT);
    statusBar.setForegroundColor(ColorHelper.WHITE);
    statusBar.setBackgroundColor(ColorHelper.BLUE);
    showText(getWelcomeScreen());
    int in;
    int offset=0;
    InputAction inputAction=null;
    long lastEvent=SystemClock.uptimeMillis();
    while (true) {
      in=m_IO.read();
      if (in == TerminalIO.IOERROR || in == TerminalIO.HANDLED) {
        break;
      }
      if (offset == 0) {
        inputAction=getFreeInputAction();
        inputAction.inUse=true;
        inputAction.symbol=in;
        inputAction.sequence=inputAction.buffer[InputAction.getBuffer(in)];
      }
      inputAction.sequence[offset]=(byte)in;
      offset++;
      if (offset == inputAction.sequence.length) {
        offset=0;
        inputAction.myService=RemoteKeyboardService.self;
        long now=SystemClock.uptimeMillis();
        ;
        if ((now - lastEvent) > 30) {
          try {
            Thread.sleep(30);
          }
 catch (          InterruptedException e) {
          }
        }
        lastEvent=now;
        RemoteKeyboardService.self.handler.post(inputAction);
      }
    }
    m_IO.eraseScreen();
    m_IO.flush();
  }
 catch (  EOFException e) {
  }
catch (  IOException e) {
    Log.w(TAG,e);
  }
 finally {
    RemoteKeyboardService.self.updateNotification(null);
    wakeLock.release();
    self=null;
  }
}

Fixed version (ground truth):
@Override public void run(Connection con){
  m_IO=con.getTerminalIO();
  PowerManager pm=(PowerManager)RemoteKeyboardService.self.getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock wakeLock=pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,TAG);
  wakeLock.acquire();
  Resources res=RemoteKeyboardService.self.getResources();
  RemoteKeyboardService.self.updateNotification(con.getConnectionData().getInetAddress());
  try {
    titleBar=new Titlebar(m_IO,"String_Node_Str");
    titleBar.setTitleText(res.getString(R.string.terminal_title));
    titleBar.setAlignment(Titlebar.ALIGN_LEFT);
    titleBar.setForegroundColor(ColorHelper.WHITE);
    titleBar.setBackgroundColor(ColorHelper.BLUE);
    content=new Label(m_IO,"String_Node_Str");
    content.setLocation(0,2);
    statusBar=new Statusbar(m_IO,"String_Node_Str");
    statusBar.setStatusText(res.getString(R.string.terminal_statusbar));
    statusBar.setAlignment(Titlebar.ALIGN_LEFT);
    statusBar.setForegroundColor(ColorHelper.WHITE);
    statusBar.setBackgroundColor(ColorHelper.BLUE);
    showText(getWelcomeScreen());
    int in;
    int offset=0;
    InputAction inputAction=new InputAction();
    ActionRunner actionRunner=new ActionRunner();
    while (true) {
      in=m_IO.read();
      if (in == TerminalIO.IOERROR || in == TerminalIO.HANDLED) {
        break;
      }
      if (offset == 0) {
        inputAction.symbol=in;
        inputAction.sequence=inputAction.buffer[InputAction.getBuffer(in)];
      }
      inputAction.sequence[offset]=(byte)in;
      offset++;
      if (offset == inputAction.sequence.length) {
        offset=0;
        inputAction.myService=RemoteKeyboardService.self;
        actionRunner.setAction(inputAction);
        RemoteKeyboardService.self.handler.post(actionRunner);
        actionRunner.waitResult();
      }
    }
    m_IO.eraseScreen();
    m_IO.flush();
  }
 catch (  EOFException e) {
  }
catch (  IOException e) {
    Log.w(TAG,e);
  }
 finally {
    RemoteKeyboardService.self.updateNotification(null);
    wakeLock.release();
    self=null;
  }
}