Program: 182738
Project: 182738
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  int widthMode=MeasureSpec.getMode(widthMeasureSpec);
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  int widthSize=MeasureSpec.getSize(widthMeasureSpec);
  int heightSize=MeasureSpec.getSize(heightMeasureSpec);
  if (widthMode == MeasureSpec.UNSPECIFIED) {
    if (mColumnWidth > 0) {
      widthSize=mColumnWidth + mListPadding.left + mListPadding.right;
    }
 else {
      widthSize=mListPadding.left + mListPadding.right;
    }
    widthSize+=getVerticalScrollbarWidth();
  }
  int childWidth=widthSize - mListPadding.left - mListPadding.right;
  determineColumns(childWidth);
  int childHeight=0;
  mItemCount=mAdapter == null ? 0 : mAdapter.getCount();
  final int count=mItemCount;
  if (count > 0) {
    final View child=obtainView(0);
    AbsListView.LayoutParams p=(AbsListView.LayoutParams)child.getLayoutParams();
    if (p == null) {
      p=new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0);
      child.setLayoutParams(p);
    }
    p.viewType=mAdapter.getItemViewType(0);
    int childHeightSpec=getChildMeasureSpec(MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED),0,p.height);
    int childWidthSpec=getChildMeasureSpec(MeasureSpec.makeMeasureSpec(mColumnWidth,MeasureSpec.EXACTLY),0,p.width);
    child.measure(childWidthSpec,childHeightSpec);
    childHeight=child.getMeasuredHeight();
    if (mRecycler.shouldRecycleViewType(p.viewType)) {
      mRecycler.addScrapView(child);
    }
  }
  if (heightMode == MeasureSpec.UNSPECIFIED) {
    heightSize=mListPadding.top + mListPadding.bottom + childHeight+ getVerticalFadingEdgeLength() * 2;
  }
  if (heightMode == MeasureSpec.AT_MOST) {
    int ourSize=mListPadding.top + mListPadding.bottom;
    final int numColumns=mNumColumns;
    for (int i=0; i < count; i+=numColumns) {
      ourSize+=childHeight;
      if (i + numColumns < count) {
        ourSize+=mVerticalSpacing;
      }
      if (ourSize >= heightSize) {
        ourSize=heightSize;
        break;
      }
    }
    heightSize=ourSize;
  }
  setMeasuredDimension(widthSize,heightSize);
  mWidthMeasureSpec=widthMeasureSpec;
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  int widthMode=MeasureSpec.getMode(widthMeasureSpec);
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  int widthSize=MeasureSpec.getSize(widthMeasureSpec);
  int heightSize=MeasureSpec.getSize(heightMeasureSpec);
  if (widthMode == MeasureSpec.UNSPECIFIED) {
    if (mColumnWidth > 0) {
      widthSize=mColumnWidth + mListPadding.left + mListPadding.right;
    }
 else {
      widthSize=mListPadding.left + mListPadding.right;
    }
    widthSize+=getVerticalScrollbarWidth();
  }
  int childWidth=widthSize - mListPadding.left - mListPadding.right;
  determineColumns(childWidth);
  int childHeight=0;
  mItemCount=mAdapter == null ? 0 : mAdapter.getCount();
  final int count=mItemCount;
  if (count > 0) {
    final View child=obtainView(0,mIsScrap);
    AbsListView.LayoutParams p=(AbsListView.LayoutParams)child.getLayoutParams();
    if (p == null) {
      p=new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0);
      child.setLayoutParams(p);
    }
    p.viewType=mAdapter.getItemViewType(0);
    int childHeightSpec=getChildMeasureSpec(MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED),0,p.height);
    int childWidthSpec=getChildMeasureSpec(MeasureSpec.makeMeasureSpec(mColumnWidth,MeasureSpec.EXACTLY),0,p.width);
    child.measure(childWidthSpec,childHeightSpec);
    childHeight=child.getMeasuredHeight();
    if (mRecycler.shouldRecycleViewType(p.viewType)) {
      mRecycler.addScrapView(child);
    }
  }
  if (heightMode == MeasureSpec.UNSPECIFIED) {
    heightSize=mListPadding.top + mListPadding.bottom + childHeight+ getVerticalFadingEdgeLength() * 2;
  }
  if (heightMode == MeasureSpec.AT_MOST) {
    int ourSize=mListPadding.top + mListPadding.bottom;
    final int numColumns=mNumColumns;
    for (int i=0; i < count; i+=numColumns) {
      ourSize+=childHeight;
      if (i + numColumns < count) {
        ourSize+=mVerticalSpacing;
      }
      if (ourSize >= heightSize) {
        ourSize=heightSize;
        break;
      }
    }
    heightSize=ourSize;
  }
  setMeasuredDimension(widthSize,heightSize);
  mWidthMeasureSpec=widthMeasureSpec;
}