Program: 152046
Project: 152046
Buggy source:
@Override protected void renderComponent(Renderer renderer){
  super.renderComponent(renderer);
  Insets insets=getInsets();
  int lineHeight=getTextFactory().getHeight();
  if (_showCursor && (_cursp != _selp)) {
    Background bkg=getSelectionBackground();
    if (bkg != null) {
      int startP=Math.min(_cursp,_selp);
      int endP=Math.max(_cursp,_selp);
      Point startLoc=(startP == _cursp) ? _curs : _sel;
      Point endLoc=(startP == _cursp) ? _sel : _curs;
      if (startLoc.y == endLoc.y) {
        bkg.render(renderer,insets.left + startLoc.x,insets.bottom + startLoc.y,endLoc.x - startLoc.x + 1,lineHeight,_alpha);
      }
 else {
        int pos=0;
        boolean started=false;
        int y=_height - insets.top - lineHeight;
        for (        Text text : _glyphs) {
          int length=text.getLength();
          if (started) {
            if (endP < (pos + length)) {
              bkg.render(renderer,insets.left,insets.bottom + endLoc.y,endLoc.x + 1,lineHeight,_alpha);
              break;
            }
            bkg.render(renderer,insets.left,y,text.getSize().width + 1,lineHeight,_alpha);
          }
 else {
            if (startP < (pos + length)) {
              bkg.render(renderer,insets.left + startLoc.x,insets.bottom + startLoc.y,text.getSize().width - startLoc.x,lineHeight,_alpha);
              started=true;
            }
          }
          pos+=length;
          y-=lineHeight;
        }
      }
    }
  }
  if (_glyphs != null) {
    int x=insets.left;
    int y=_height - insets.top - lineHeight;
    for (    Text text : _glyphs) {
      text.render(renderer,x,y,_alpha);
      y-=lineHeight;
    }
  }
  if (_showCursor && (_cursp == _selp)) {
    renderCursor(renderer,insets.left + _curs.x,insets.bottom + _curs.y,lineHeight);
  }
}

Fixed version (ground truth):
@Override protected void renderComponent(Renderer renderer){
  super.renderComponent(renderer);
  Insets insets=getInsets();
  int lineHeight=getTextFactory().getHeight();
  if (_showCursor && (_cursp != _selp)) {
    Background bkg=getSelectionBackground();
    if (bkg != null) {
      int startP=Math.min(_cursp,_selp);
      int endP=Math.max(_cursp,_selp);
      Point startLoc=(startP == _cursp) ? _curs : _sel;
      Point endLoc=(startP == _cursp) ? _sel : _curs;
      if (startLoc.y == endLoc.y) {
        bkg.render(renderer,insets.left + startLoc.x,insets.bottom + startLoc.y,endLoc.x - startLoc.x + 1,lineHeight,_alpha);
      }
 else {
        int idx=((_height - insets.getVertical() - startLoc.y) / lineHeight) - 1;
        bkg.render(renderer,insets.left + startLoc.x,insets.bottom + startLoc.y,_glyphs[idx].getSize().width - startLoc.x + 1,lineHeight,_alpha);
        for (int y=startLoc.y - lineHeight; y > endLoc.y; y-=lineHeight) {
          bkg.render(renderer,insets.left,insets.bottom + y,_glyphs[++idx].getSize().width + 1,lineHeight,_alpha);
        }
        bkg.render(renderer,insets.left,insets.bottom + endLoc.y,endLoc.x + 1,lineHeight,_alpha);
      }
    }
  }
  if (_glyphs != null) {
    int x=insets.left;
    int y=_height - insets.top - lineHeight;
    for (    Text text : _glyphs) {
      text.render(renderer,x,y,_alpha);
      y-=lineHeight;
    }
  }
  if (_showCursor && (_cursp == _selp)) {
    renderCursor(renderer,insets.left + _curs.x,insets.bottom + _curs.y,lineHeight);
  }
}