Program: 58805
Project: 58805
Buggy source:
/** 
 * <p> Initializes a sub menu and recursively initializes the sub menus of the items in contextMenuEntries. Sets unique IDs for every element and creates the ContextMenuMetaData objects for sub menus. </p> <p> Sets the width and height of a sub menu. The origin in X and Y have to be set at another place before calling this method. </p>
 * @param contextMenuEntries the list of context menu items for the current sub menu
 * @param metaData The metaData information for the current sub menu. height and widht are set, origin hast to be set before.
 * @throws IllegalStateException if xOrigin and yOrigin in metaData have not been initialized.
 */
private void initializeSubMenus(ArrayList<IContextMenuEntry> contextMenuItems,ContextMenuMetaData metaData){
  metaData.maxTextWidth=0;
  for (  IContextMenuEntry entry : contextMenuItems) {
    if (entry instanceof AContextMenuItem) {
      AContextMenuItem item=(AContextMenuItem)entry;
      hashUniqueIDToContextMenuItem.put(iPickingIDCounter,item);
      hashContextMenuItemToUniqueID.put(item,iPickingIDCounter++);
      float textWidth=(float)textRenderer.getBounds(item.getText()).getWidth() * FONT_SCALING;
      if (textWidth > metaData.maxTextWidth)       metaData.maxTextWidth=textWidth;
      if (item.hasSubItems()) {
        ContextMenuMetaData newMetaData=new ContextMenuMetaData();
        hashContextMenuItemToMetaData.put(item,newMetaData);
        initializeSubMenus(item.getSubItems(),newMetaData);
      }
    }
  }
  metaData.width=metaData.maxTextWidth + WIDHT_OVERHEAD;
  metaData.height=contextMenuItems.size() * ITEM_HEIGHT + HEIGHT_OVERHEAD;
}

Fixed version (ground truth):
/** 
 * <p> Initializes a sub menu and recursively initializes the sub menus of the items in contextMenuEntries. Sets unique IDs for every element and creates the ContextMenuMetaData objects for sub menus. </p> <p> Sets the width and height of a sub menu. The origin in X and Y have to be set at another place before calling this method. </p>
 * @param contextMenuEntries the list of context menu items for the current sub menu
 * @param metaData The metaData information for the current sub menu. height and widht are set, origin hast to be set before.
 * @throws IllegalStateException if xOrigin and yOrigin in metaData have not been initialized.
 */
private void initializeSubMenus(ArrayList<IContextMenuEntry> contextMenuItems,ContextMenuMetaData metaData){
  metaData.maxTextWidth=0;
  for (  IContextMenuEntry entry : contextMenuItems) {
    if (entry instanceof AContextMenuItem) {
      AContextMenuItem item=(AContextMenuItem)entry;
      hashUniqueIDToContextMenuItem.put(iPickingIDCounter,item);
      hashContextMenuItemToUniqueID.put(item,iPickingIDCounter++);
      float textWidth=(float)textRenderer.getBounds(item.getText()).getWidth() * FONT_SCALING;
      if (textWidth > metaData.maxTextWidth)       metaData.maxTextWidth=textWidth;
      if (item.hasSubItems()) {
        ContextMenuMetaData newMetaData=new ContextMenuMetaData();
        hashContextMenuItemToMetaData.put(item,newMetaData);
        initializeSubMenus(item.getSubItems(),newMetaData);
      }
    }
 else     if (entry instanceof Heading) {
      Heading heading=(Heading)entry;
      float textWidth=(float)textRenderer.getBounds(heading.getText()).getWidth() * FONT_SCALING;
      textWidth-=ICON_SIZE - SPACING;
      if (textWidth > metaData.maxTextWidth)       metaData.maxTextWidth=textWidth;
    }
  }
  metaData.width=metaData.maxTextWidth + WIDHT_OVERHEAD;
  metaData.height=contextMenuItems.size() * ITEM_HEIGHT + HEIGHT_OVERHEAD;
}