Program: 193607
Project: 193607
Buggy source:
@Override public void addMenu(MenuBuilder menu){
  boolean addSubMenu=mListViews.size() > 0;
  menu.addMenuPresenter(this,mContext);
  MenuPopupWindow popupWindow=createPopupWindow();
  MenuAdapter adapter=new MenuAdapter(menu,LayoutInflater.from(mContext),mOverflowOnly);
  adapter.setForceShowIcon(mForceShowIcon);
  popupWindow.setAdapter(adapter);
  int menuWidth=measureIndividualMenuWidth(adapter,null,mContext,mMenuMaxWidth);
  int x=0;
  int y=0;
  if (addSubMenu) {
    popupWindow.setTouchModal(false);
    popupWindow.setEnterTransition(null);
    ListView lastListView=mListViews.get(mListViews.size() - 1);
    @HorizPosition int nextMenuPosition=getNextMenuPosition(menuWidth);
    boolean showOnRight=nextMenuPosition == HORIZ_POSITION_RIGHT;
    mPreferredPosition=nextMenuPosition;
    int[] lastLocation=new int[2];
    lastListView.getLocationOnScreen(lastLocation);
    int[] lastOffset=mOffsets.get(mOffsets.size() - 1);
    if ((mDropDownGravity & Gravity.RIGHT) == Gravity.RIGHT) {
      if (showOnRight) {
        x=lastOffset[0] + menuWidth;
      }
 else {
        x=lastOffset[0] - lastListView.getWidth();
      }
    }
 else {
      if (showOnRight) {
        x=lastOffset[0] + lastListView.getWidth();
      }
 else {
        x=lastOffset[0] - menuWidth;
      }
    }
    y=lastOffset[1] + lastListView.getSelectedView().getTop() - lastListView.getChildAt(0).getTop();
  }
  popupWindow.setWidth(menuWidth);
  popupWindow.setHorizontalOffset(x);
  popupWindow.setVerticalOffset(y);
  mPopupWindows.add(popupWindow);
  if (isShowing()) {
    popupWindow.show();
    mListViews.add((DropDownListView)popupWindow.getListView());
  }
  int[] offsets={x,y};
  mOffsets.add(offsets);
}

Fixed version (ground truth):
@Override public void addMenu(MenuBuilder menu){
  boolean addSubMenu=mListViews.size() > 0;
  menu.addMenuPresenter(this,mContext);
  MenuPopupWindow popupWindow=createPopupWindow();
  MenuAdapter adapter=new MenuAdapter(menu,LayoutInflater.from(mContext),mOverflowOnly);
  adapter.setForceShowIcon(mForceShowIcon);
  popupWindow.setAdapter(adapter);
  int menuWidth=measureIndividualMenuWidth(adapter,null,mContext,mMenuMaxWidth);
  int x=0;
  int y=0;
  if (addSubMenu) {
    popupWindow.setTouchModal(false);
    popupWindow.setEnterTransition(null);
    ListView lastListView=mListViews.get(mListViews.size() - 1);
    @HorizPosition int nextMenuPosition=getNextMenuPosition(menuWidth);
    boolean showOnRight=nextMenuPosition == HORIZ_POSITION_RIGHT;
    mLastPosition=nextMenuPosition;
    int[] lastLocation=new int[2];
    lastListView.getLocationOnScreen(lastLocation);
    int[] lastOffset=mOffsets.get(mOffsets.size() - 1);
    if ((mDropDownGravity & Gravity.RIGHT) == Gravity.RIGHT) {
      if (showOnRight) {
        x=lastOffset[0] + menuWidth;
      }
 else {
        x=lastOffset[0] - lastListView.getWidth();
      }
    }
 else {
      if (showOnRight) {
        x=lastOffset[0] + lastListView.getWidth();
      }
 else {
        x=lastOffset[0] - menuWidth;
      }
    }
    y=lastOffset[1] + lastListView.getSelectedView().getTop() - lastListView.getChildAt(0).getTop();
  }
  popupWindow.setWidth(menuWidth);
  popupWindow.setHorizontalOffset(x);
  popupWindow.setVerticalOffset(y);
  mPopupWindows.add(popupWindow);
  if (isShowing()) {
    popupWindow.show();
    mListViews.add((DropDownListView)popupWindow.getListView());
  }
  int[] offsets={x,y};
  mOffsets.add(offsets);
  mPositions.add(mLastPosition);
}