Program: 60105
Project: 60105
Buggy source:
/** 
 * Layout text.
 * @param textNode the text node
 */
private void layoutText(DOMNodeImpl textNode){
  RenderState renderState=textNode.getRenderState();
  if (renderState == null) {
    throw new IllegalStateException("String_Node_Str" + textNode + "String_Node_Str"+ textNode.getParentNode());
  }
  FontMetrics fm=renderState.getFontMetrics();
  int descent=fm.getDescent();
  int ascentPlusLeading=fm.getAscent() + fm.getLeading();
  int wordHeight=fm.getHeight();
  int blankWidth=fm.charWidth(' ');
  int whiteSpace=this.overrideNoWrap ? RenderState.WS_NOWRAP : renderState.getWhiteSpace();
  int textTransform=renderState.getTextTransform();
  String text=textNode.getNodeValue();
  if (whiteSpace != RenderState.WS_PRE) {
    boolean prevAllowOverflow=this.currentLine.isAllowOverflow();
    boolean allowOverflow=whiteSpace == RenderState.WS_NOWRAP;
    this.currentLine.setAllowOverflow(allowOverflow);
    try {
      int length=text.length();
      StringBuffer word=new StringBuffer(12);
      for (int i=0; i < length; i++) {
        char ch=text.charAt(i);
        if (Character.isWhitespace(ch)) {
          int wlen=word.length();
          if (wlen > 0) {
            RWord rword=new RWord(textNode,word.toString(),container,fm,descent,ascentPlusLeading,wordHeight,textTransform);
            this.addWordToLine(rword);
            word.delete(0,wlen);
          }
          RLine line=this.currentLine;
          if (line.width > 0) {
            logger.error("String_Node_Str" + textNode.getTextContent());
            RBlank rblank=new RBlank(textNode,fm,container,ascentPlusLeading,blankWidth,wordHeight);
            line.addBlank(rblank);
          }
          for (i++; i < length; i++) {
            ch=text.charAt(i);
            if (!Character.isWhitespace(ch)) {
              word.append(ch);
              break;
            }
          }
        }
 else {
          word.append(ch);
        }
      }
      if (word.length() > 0) {
        RWord rword=new RWord(textNode,word.toString(),container,fm,descent,ascentPlusLeading,wordHeight,textTransform);
        this.addWordToLine(rword);
      }
    }
  finally {
      this.currentLine.setAllowOverflow(prevAllowOverflow);
    }
  }
 else {
    int length=text.length();
    boolean lastCharSlashR=false;
    StringBuffer line=new StringBuffer();
    for (int i=0; i < length; i++) {
      char ch=text.charAt(i);
switch (ch) {
case '\r':
        lastCharSlashR=true;
      break;
case '\n':
    int llen=line.length();
  if (llen > 0) {
    RWord rword=new RWord(textNode,line.toString(),container,fm,descent,ascentPlusLeading,wordHeight,textTransform);
    this.addWordToLine(rword);
    line.delete(0,line.length());
  }
RLine prevLine=this.currentLine;
prevLine.setLineBreak(new LineBreak(LineBreak.NONE,textNode));
this.addLine(textNode,prevLine,prevLine.y + prevLine.height);
break;
default :
if (lastCharSlashR) {
line.append('\r');
lastCharSlashR=false;
}
line.append(ch);
break;
}
}
if (line.length() > 0) {
RWord rword=new RWord(textNode,line.toString(),container,fm,descent,ascentPlusLeading,wordHeight,textTransform);
this.addWordToLine(rword);
}
}
}

Fixed version (ground truth):
/** 
 * Layout text.
 * @param textNode the text node
 */
private void layoutText(DOMNodeImpl textNode){
  RenderState renderState=textNode.getRenderState();
  if (renderState == null) {
    throw new IllegalStateException("String_Node_Str" + textNode + "String_Node_Str"+ textNode.getParentNode());
  }
  FontMetrics fm=renderState.getFontMetrics();
  int descent=fm.getDescent();
  int ascentPlusLeading=fm.getAscent() + fm.getLeading();
  int wordHeight=fm.getHeight();
  int blankWidth=fm.charWidth(' ');
  int whiteSpace=this.overrideNoWrap ? RenderState.WS_NOWRAP : renderState.getWhiteSpace();
  int textTransform=renderState.getTextTransform();
  String text=textNode.getNodeValue();
  if (whiteSpace != RenderState.WS_PRE) {
    boolean prevAllowOverflow=this.currentLine.isAllowOverflow();
    boolean allowOverflow=whiteSpace == RenderState.WS_NOWRAP;
    this.currentLine.setAllowOverflow(allowOverflow);
    try {
      int length=text.length();
      StringBuffer word=new StringBuffer(12);
      for (int i=0; i < length; i++) {
        char ch=text.charAt(i);
        if (Character.isWhitespace(ch)) {
          int wlen=word.length();
          if (wlen > 0) {
            RWord rword=new RWord(textNode,word.toString(),container,fm,descent,ascentPlusLeading,wordHeight,textTransform);
            this.addWordToLine(rword);
            word.delete(0,wlen);
          }
          RLine line=this.currentLine;
          if (line.width > 0) {
            RBlank rblank=new RBlank(textNode,fm,container,ascentPlusLeading,blankWidth,wordHeight);
            line.addBlank(rblank);
          }
          for (i++; i < length; i++) {
            ch=text.charAt(i);
            if (!Character.isWhitespace(ch)) {
              word.append(ch);
              break;
            }
          }
        }
 else {
          word.append(ch);
        }
      }
      if (word.length() > 0) {
        RWord rword=new RWord(textNode,word.toString(),container,fm,descent,ascentPlusLeading,wordHeight,textTransform);
        this.addWordToLine(rword);
      }
    }
  finally {
      this.currentLine.setAllowOverflow(prevAllowOverflow);
    }
  }
 else {
    int length=text.length();
    boolean lastCharSlashR=false;
    StringBuffer line=new StringBuffer();
    for (int i=0; i < length; i++) {
      char ch=text.charAt(i);
switch (ch) {
case '\r':
        lastCharSlashR=true;
      break;
case '\n':
    int llen=line.length();
  if (llen > 0) {
    RWord rword=new RWord(textNode,line.toString(),container,fm,descent,ascentPlusLeading,wordHeight,textTransform);
    this.addWordToLine(rword);
    line.delete(0,line.length());
  }
RLine prevLine=this.currentLine;
prevLine.setLineBreak(new LineBreak(LineBreak.NONE,textNode));
this.addLine(textNode,prevLine,prevLine.y + prevLine.height);
break;
default :
if (lastCharSlashR) {
line.append('\r');
lastCharSlashR=false;
}
line.append(ch);
break;
}
}
if (line.length() > 0) {
RWord rword=new RWord(textNode,line.toString(),container,fm,descent,ascentPlusLeading,wordHeight,textTransform);
this.addWordToLine(rword);
}
}
}