Program: 75521
Project: 75521
Buggy source:
protected void align(boolean lastLine){
  if (root == null) {
    return;
  }
  assert(parent instanceof PDFBlockStackingLM);
  String align=((PDFBlockStackingLM)parent).getTextAlign();
  if ((CSSConstants.CSS_RIGHT_VALUE.equalsIgnoreCase(align) || CSSConstants.CSS_CENTER_VALUE.equalsIgnoreCase(align))) {
    int spacing=root.getContentWidth() - getCurrentIP();
    Iterator iter=root.getChildren();
    while (iter.hasNext()) {
      AbstractArea area=(AbstractArea)iter.next();
      if (CSSConstants.CSS_RIGHT_VALUE.equalsIgnoreCase(align)) {
        area.setAllocatedPosition(spacing + area.getAllocatedX(),area.getAllocatedY());
      }
 else       if (CSSConstants.CSS_CENTER_VALUE.equalsIgnoreCase(align)) {
        area.setAllocatedPosition(spacing / 2 + area.getAllocatedX(),area.getAllocatedY());
      }
    }
  }
 else   if (CSSConstants.CSS_JUSTIFY_VALUE.equalsIgnoreCase(align) && !lastLine) {
    justify();
  }
  Iterator iter=root.getChildren();
  int height=root.getHeight();
  while (iter.hasNext()) {
    AbstractArea child=(AbstractArea)iter.next();
    IStyle childStyle=child.getStyle();
    String vAlign=childStyle.getVerticalAlign();
    if (childStyle != null) {
      int spacing=height - child.getAllocatedHeight();
      assert(spacing >= 0);
      if (CSSConstants.CSS_BOTTOM_VALUE.equalsIgnoreCase(vAlign) || CSSConstants.CSS_BASELINE_VALUE.equalsIgnoreCase(vAlign)) {
        child.setPosition(child.getX(),spacing + child.getY());
      }
 else       if (CSSConstants.CSS_MIDDLE_VALUE.equalsIgnoreCase(vAlign)) {
        child.setPosition(child.getX(),spacing / 2 + child.getY());
      }
 else {
        int lineHeight=((PDFBlockStackingLM)parent).getLineHeight();
        if (lineHeight > 0) {
          child.setPosition(child.getX(),spacing / 2 + child.getY());
        }
      }
    }
  }
}

Fixed version (ground truth):
protected void align(boolean lastLine){
  if (root == null) {
    return;
  }
  assert(parent instanceof PDFBlockStackingLM);
  String align=((PDFBlockStackingLM)parent).getTextAlign();
  if ((CSSConstants.CSS_RIGHT_VALUE.equalsIgnoreCase(align) || CSSConstants.CSS_CENTER_VALUE.equalsIgnoreCase(align))) {
    int spacing=root.getContentWidth() - getCurrentIP();
    Iterator iter=root.getChildren();
    while (iter.hasNext()) {
      AbstractArea area=(AbstractArea)iter.next();
      if (CSSConstants.CSS_RIGHT_VALUE.equalsIgnoreCase(align)) {
        area.setAllocatedPosition(spacing + area.getAllocatedX(),area.getAllocatedY());
      }
 else       if (CSSConstants.CSS_CENTER_VALUE.equalsIgnoreCase(align)) {
        area.setAllocatedPosition(spacing / 2 + area.getAllocatedX(),area.getAllocatedY());
      }
    }
  }
 else   if (CSSConstants.CSS_JUSTIFY_VALUE.equalsIgnoreCase(align) && !lastLine) {
    justify();
  }
  Iterator iter=root.getChildren();
  int height=root.getHeight();
  while (iter.hasNext()) {
    AbstractArea child=(AbstractArea)iter.next();
    IStyle childStyle=child.getStyle();
    String vAlign=childStyle.getVerticalAlign();
    if (childStyle != null) {
      int spacing=height - child.getAllocatedHeight();
      assert(spacing >= 0);
      if (CSSConstants.CSS_BOTTOM_VALUE.equalsIgnoreCase(vAlign)) {
        child.setPosition(child.getX(),spacing + child.getY());
      }
 else       if (CSSConstants.CSS_MIDDLE_VALUE.equalsIgnoreCase(vAlign) || CSSConstants.CSS_BASELINE_VALUE.equalsIgnoreCase(vAlign)) {
        child.setPosition(child.getX(),spacing / 2 + child.getY());
      }
 else {
        int lineHeight=((PDFBlockStackingLM)parent).getLineHeight();
        if (lineHeight > 0) {
          child.setPosition(child.getX(),spacing / 2 + child.getY());
        }
      }
    }
  }
}