Program: 14432
Project: 14432
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  int itemId=item.getItemId();
  if (itemId == android.R.id.home) {
    FragmentManager fm=getFragmentManager();
    if (fm.getBackStackEntryCount() > 0) {
      fm.popBackStack();
      setupBaseLayout();
      return true;
    }
  }
 else   if (itemId == R.id.menu_new_media) {
    View view=findViewById(R.id.menu_new_media);
    if (view != null) {
      int y_offset=getResources().getDimensionPixelSize(R.dimen.action_bar_spinner_y_offset);
      int[] loc=new int[2];
      view.getLocationOnScreen(loc);
      mAddMediaPopup.showAtLocation(view,Gravity.TOP | Gravity.LEFT,loc[0],loc[1] + view.getHeight() + y_offset);
    }
 else {
      View gridView=findViewById(R.id.media_gridview);
      mAddMediaPopup.showAtLocation(gridView,Gravity.CENTER,0,0);
    }
    return true;
  }
 else   if (itemId == R.id.menu_search) {
    mSearchMenuItem=item;
    mSearchMenuItem.setOnActionExpandListener(this);
    mSearchMenuItem.expandActionView();
    mSearchView=(SearchView)item.getActionView();
    mSearchView.setOnQueryTextListener(this);
    if (!TextUtils.isEmpty(mQuery)) {
      onQueryTextSubmit(mQuery);
      mSearchView.setQuery(mQuery,true);
    }
    return true;
  }
 else   if (itemId == R.id.menu_edit_media) {
    String mediaId=mMediaItemFragment.getMediaId();
    FragmentManager fm=getFragmentManager();
    if (mMediaEditFragment == null || !mMediaEditFragment.isInLayout()) {
      FragmentTransaction ft=fm.beginTransaction();
      if (mMediaItemFragment.isVisible())       ft.hide(mMediaItemFragment);
      mMediaEditFragment=MediaEditFragment.newInstance(mediaId);
      ft.add(R.id.media_browser_container,mMediaEditFragment,MediaEditFragment.TAG);
      ft.addToBackStack(null);
      ft.commit();
      if (getDrawerToggle() != null) {
        getDrawerToggle().setDrawerIndicatorEnabled(false);
      }
    }
 else {
      mMediaEditFragment.loadMedia(mediaId);
    }
    if (mSearchView != null) {
      mSearchView.clearFocus();
    }
  }
  return super.onOptionsItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  int itemId=item.getItemId();
  if (itemId == R.id.menu_new_media) {
    View view=findViewById(R.id.menu_new_media);
    if (view != null) {
      int y_offset=getResources().getDimensionPixelSize(R.dimen.action_bar_spinner_y_offset);
      int[] loc=new int[2];
      view.getLocationOnScreen(loc);
      mAddMediaPopup.showAtLocation(view,Gravity.TOP | Gravity.LEFT,loc[0],loc[1] + view.getHeight() + y_offset);
    }
 else {
      View gridView=findViewById(R.id.media_gridview);
      mAddMediaPopup.showAtLocation(gridView,Gravity.CENTER,0,0);
    }
    return true;
  }
 else   if (itemId == R.id.menu_search) {
    mSearchMenuItem=item;
    mSearchMenuItem.setOnActionExpandListener(this);
    mSearchMenuItem.expandActionView();
    mSearchView=(SearchView)item.getActionView();
    mSearchView.setOnQueryTextListener(this);
    if (!TextUtils.isEmpty(mQuery)) {
      onQueryTextSubmit(mQuery);
      mSearchView.setQuery(mQuery,true);
    }
    return true;
  }
 else   if (itemId == R.id.menu_edit_media) {
    String mediaId=mMediaItemFragment.getMediaId();
    FragmentManager fm=getFragmentManager();
    if (mMediaEditFragment == null || !mMediaEditFragment.isInLayout()) {
      FragmentTransaction ft=fm.beginTransaction();
      if (mMediaItemFragment.isVisible())       ft.hide(mMediaItemFragment);
      mMediaEditFragment=MediaEditFragment.newInstance(mediaId);
      ft.add(R.id.media_browser_container,mMediaEditFragment,MediaEditFragment.TAG);
      ft.addToBackStack(null);
      ft.commit();
      if (getDrawerToggle() != null) {
        getDrawerToggle().setDrawerIndicatorEnabled(false);
      }
    }
 else {
      mMediaEditFragment.loadMedia(mediaId);
    }
    if (mSearchView != null) {
      mSearchView.clearFocus();
    }
  }
  return super.onOptionsItemSelected(item);
}