Program: 104974
Project: 104974
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  int sizeWidth=MeasureSpec.getSize(widthMeasureSpec);
  int sizeHeight=MeasureSpec.getSize(heightMeasureSpec);
  int modeWidth=MeasureSpec.getMode(widthMeasureSpec);
  int modeHeight=MeasureSpec.getMode(heightMeasureSpec);
  int width=0;
  int height=0;
  int lineWidth=0;
  int lineHeight=0;
  int childCount=getChildCount();
  for (int i=0; i < childCount; i++) {
    View child=getChildAt(i);
    if (child.getVisibility() == View.GONE) {
      continue;
    }
    LayoutParams lp=(LayoutParams)child.getLayoutParams();
    int childWidthMode=MeasureSpec.AT_MOST;
    int childWidthSize=sizeWidth;
    int childHeightMode=MeasureSpec.AT_MOST;
    int childHeightSize=sizeHeight;
    if (lp.width == LayoutParams.MATCH_PARENT) {
      childWidthMode=MeasureSpec.EXACTLY;
      childWidthSize-=lp.leftMargin + lp.rightMargin;
    }
 else     if (lp.width >= 0) {
      childWidthMode=MeasureSpec.EXACTLY;
      childWidthSize=lp.width;
    }
    if (lp.height >= 0) {
      childHeightMode=MeasureSpec.EXACTLY;
      childHeightSize=lp.height;
    }
    child.measure(MeasureSpec.makeMeasureSpec(childWidthSize,childWidthMode),MeasureSpec.makeMeasureSpec(childHeightSize,childHeightMode));
    int childWidth=child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;
    if (lineWidth + childWidth > sizeWidth) {
      width=Math.max(width,lineWidth);
      lineWidth=childWidth;
      height+=lineHeight;
      lineHeight=Math.max(lineHeight,child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
    }
 else {
      lineWidth+=childWidth;
      lineHeight=Math.max(lineHeight,child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
    }
    if (i == childCount - 1) {
      width=Math.max(width,lineWidth);
      height+=lineHeight;
    }
  }
  setMeasuredDimension((modeWidth == MeasureSpec.EXACTLY) ? sizeWidth : width,(modeHeight == MeasureSpec.EXACTLY) ? sizeHeight : height);
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  int sizeWidth=MeasureSpec.getSize(widthMeasureSpec);
  int sizeHeight=MeasureSpec.getSize(heightMeasureSpec);
  int modeWidth=MeasureSpec.getMode(widthMeasureSpec);
  int modeHeight=MeasureSpec.getMode(heightMeasureSpec);
  int width=0;
  int height=0;
  int lineWidth=0;
  int lineHeight=0;
  int childCount=getChildCount();
  for (int i=0; i < childCount; i++) {
    View child=getChildAt(i);
    if (child.getVisibility() == View.GONE) {
      if (i == childCount - 1) {
        width=Math.max(width,lineWidth);
        height+=lineHeight;
      }
      continue;
    }
    LayoutParams lp=(LayoutParams)child.getLayoutParams();
    int childWidthMode=MeasureSpec.AT_MOST;
    int childWidthSize=sizeWidth;
    int childHeightMode=MeasureSpec.AT_MOST;
    int childHeightSize=sizeHeight;
    if (lp.width == LayoutParams.MATCH_PARENT) {
      childWidthMode=MeasureSpec.EXACTLY;
      childWidthSize-=lp.leftMargin + lp.rightMargin;
    }
 else     if (lp.width >= 0) {
      childWidthMode=MeasureSpec.EXACTLY;
      childWidthSize=lp.width;
    }
    if (lp.height >= 0) {
      childHeightMode=MeasureSpec.EXACTLY;
      childHeightSize=lp.height;
    }
    child.measure(MeasureSpec.makeMeasureSpec(childWidthSize,childWidthMode),MeasureSpec.makeMeasureSpec(childHeightSize,childHeightMode));
    int childWidth=child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;
    if (lineWidth + childWidth > sizeWidth) {
      width=Math.max(width,lineWidth);
      lineWidth=childWidth;
      height+=lineHeight;
      lineHeight=Math.max(lineHeight,child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
    }
 else {
      lineWidth+=childWidth;
      lineHeight=Math.max(lineHeight,child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
    }
    if (i == childCount - 1) {
      width=Math.max(width,lineWidth);
      height+=lineHeight;
    }
  }
  setMeasuredDimension((modeWidth == MeasureSpec.EXACTLY) ? sizeWidth : width,(modeHeight == MeasureSpec.EXACTLY) ? sizeHeight : height);
}