Program: 11558
Project: 11558
Buggy source:
@Override protected void paintTo(GlimpseContext context,GlimpseBounds bounds){
  if (icons == null) {
    loadIcons();
  }
  if (newFont != null) {
    updateTextRenderer();
  }
  if (textLayout == null && textRenderer != null) {
    updateTextLayout();
  }
  if (lines == null && textLayout != null && text != null) {
    updateLayout();
  }
  if (textRenderer == null || lines == null)   return;
  GL2 gl=context.getGL().getGL2();
  int width=bounds.getWidth();
  int height=bounds.getHeight();
  double clampX=0;
  double clampY=0;
  if (clampToScreenEdges) {
    double maxX=x + linesBounds.maxX + offsetX;
    if (maxX > width)     clampX=width - maxX;
    double minX=x + linesBounds.minX + offsetX;
    if (minX < 0)     clampX=-minX;
    double maxY=height - y + linesBounds.maxY + offsetY;
    if (maxY > height)     clampY=height - maxY;
    double minY=height - y + linesBounds.minY + offsetY;
    if (minY < 0)     clampY=-minY;
  }
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glLoadIdentity();
  gl.glOrtho(-0.5,width - 1 + 0.5,-0.5,height - 1 + 0.5,-1,1);
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glLoadIdentity();
  gl.glBlendFunc(GL2.GL_SRC_ALPHA,GL2.GL_ONE_MINUS_SRC_ALPHA);
  gl.glEnable(GL2.GL_BLEND);
  if (this.paintBackground || this.paintBorder) {
    if (this.paintBackground) {
      gl.glColor4fv(backgroundColor,0);
      gl.glBegin(GL2.GL_QUADS);
      try {
        borderVertices(gl,height,clampX + offsetX,clampY + offsetY);
      }
  finally {
        gl.glEnd();
      }
    }
    if (this.paintBorder) {
      gl.glColor4fv(borderColor,0);
      gl.glEnable(GL2.GL_LINE_SMOOTH);
      gl.glBegin(GL2.GL_LINE_LOOP);
      try {
        borderVertices(gl,height,clampX + offsetX,clampY + offsetY);
      }
  finally {
        gl.glEnd();
      }
    }
  }
  gl.glDisable(GL2.GL_BLEND);
  GlimpseColor.setColor(textRenderer,textColor);
  textRenderer.beginRendering(width,height);
  try {
    for (int i=0; i < lines.size(); i++) {
      TextBoundingBox line=lines.get(i);
      float iconSize=getIconSpacing(i);
      int posX=(int)(x + line.leftX + iconSize+ clampX+ offsetX);
      int posY=(int)(height - y + line.getMinY() + clampY + offsetY);
      textRenderer.draw(line.text,posX,posY);
    }
  }
  finally {
    textRenderer.endRendering();
  }
  if (!lines.isEmpty() && iconIds != null && !iconIds.isEmpty()) {
    atlas.beginRendering();
    try {
      for (int i=0; i < iconIds.size(); i++) {
        Object iconId=iconIds.get(i);
        ImageData iconData=icons.get(i);
        TextBoundingBox line=lines.get(i);
        if (iconId != null && iconData != null && line != null) {
          float iconSize=getIconSize();
          double iconScale=iconSize / (double)iconData.getWidth();
          int posX=(int)(x + line.leftX + clampX+ offsetX);
          int posY=(int)(height - y + line.getMinY() + clampY + offsetY - textLayout.getDescent() * 0.25);
          float[] color=defaultIconColor;
          if (iconColors != null && i < iconColors.size()) {
            float[] iconColor=iconColors.get(i);
            if (iconColor != null) {
              color=iconColor;
            }
          }
          GlimpseColor.glColor(gl,color);
          atlas.drawImage(gl,iconId,posX,posY,iconScale,iconScale,0,iconData.getHeight());
        }
      }
    }
  finally {
      atlas.endRendering();
    }
  }
}

Fixed version (ground truth):
@Override protected void paintTo(GlimpseContext context,GlimpseBounds bounds){
  if (icons == null) {
    loadIcons();
  }
  if (newFont != null) {
    updateTextRenderer();
  }
  if (textLayout == null && textRenderer != null) {
    updateTextLayout();
  }
  if (lines == null && textLayout != null && text != null) {
    updateLayout();
  }
  final List<TextBoundingBox> tempLines=lines;
  if (textRenderer == null || tempLines == null)   return;
  GL2 gl=context.getGL().getGL2();
  int width=bounds.getWidth();
  int height=bounds.getHeight();
  double clampX=0;
  double clampY=0;
  if (clampToScreenEdges) {
    double maxX=x + linesBounds.maxX + offsetX;
    if (maxX > width)     clampX=width - maxX;
    double minX=x + linesBounds.minX + offsetX;
    if (minX < 0)     clampX=-minX;
    double maxY=height - y + linesBounds.maxY + offsetY;
    if (maxY > height)     clampY=height - maxY;
    double minY=height - y + linesBounds.minY + offsetY;
    if (minY < 0)     clampY=-minY;
  }
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glLoadIdentity();
  gl.glOrtho(-0.5,width - 1 + 0.5,-0.5,height - 1 + 0.5,-1,1);
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glLoadIdentity();
  gl.glBlendFunc(GL2.GL_SRC_ALPHA,GL2.GL_ONE_MINUS_SRC_ALPHA);
  gl.glEnable(GL2.GL_BLEND);
  if (this.paintBackground || this.paintBorder) {
    if (this.paintBackground) {
      gl.glColor4fv(backgroundColor,0);
      gl.glBegin(GL2.GL_QUADS);
      try {
        borderVertices(gl,height,clampX + offsetX,clampY + offsetY);
      }
  finally {
        gl.glEnd();
      }
    }
    if (this.paintBorder) {
      gl.glColor4fv(borderColor,0);
      gl.glEnable(GL2.GL_LINE_SMOOTH);
      gl.glBegin(GL2.GL_LINE_LOOP);
      try {
        borderVertices(gl,height,clampX + offsetX,clampY + offsetY);
      }
  finally {
        gl.glEnd();
      }
    }
  }
  gl.glDisable(GL2.GL_BLEND);
  GlimpseColor.setColor(textRenderer,textColor);
  textRenderer.beginRendering(width,height);
  try {
    for (int i=0; i < tempLines.size(); i++) {
      TextBoundingBox line=tempLines.get(i);
      float iconSize=getIconSpacing(i);
      int posX=(int)(x + line.leftX + iconSize+ clampX+ offsetX);
      int posY=(int)(height - y + line.getMinY() + clampY + offsetY);
      textRenderer.draw(line.text,posX,posY);
    }
  }
  finally {
    textRenderer.endRendering();
  }
  if (!tempLines.isEmpty() && iconIds != null && !iconIds.isEmpty()) {
    atlas.beginRendering();
    try {
      for (int i=0; i < iconIds.size(); i++) {
        Object iconId=iconIds.get(i);
        ImageData iconData=icons.get(i);
        TextBoundingBox line=tempLines.get(i);
        if (iconId != null && iconData != null && line != null) {
          float iconSize=getIconSize();
          double iconScale=iconSize / (double)iconData.getWidth();
          int posX=(int)(x + line.leftX + clampX+ offsetX);
          int posY=(int)(height - y + line.getMinY() + clampY + offsetY - textLayout.getDescent() * 0.25);
          float[] color=defaultIconColor;
          if (iconColors != null && i < iconColors.size()) {
            float[] iconColor=iconColors.get(i);
            if (iconColor != null) {
              color=iconColor;
            }
          }
          GlimpseColor.glColor(gl,color);
          atlas.drawImage(gl,iconId,posX,posY,iconScale,iconScale,0,iconData.getHeight());
        }
      }
    }
  finally {
      atlas.endRendering();
    }
  }
}