Program: 193157
Project: 193157
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  boolean limitViewHeight=shouldLimitViewHeight();
  int ownMaxHeight=limitViewHeight ? mMaxViewHeight : Integer.MAX_VALUE;
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  boolean hasFixedHeight=heightMode == MeasureSpec.EXACTLY;
  if (hasFixedHeight) {
    ownMaxHeight=Math.min(MeasureSpec.getSize(heightMeasureSpec),ownMaxHeight);
  }
  int newHeightSpec=MeasureSpec.makeMeasureSpec(ownMaxHeight,MeasureSpec.AT_MOST);
  int maxChildHeight=0;
  int childCount=getChildCount();
  for (int i=0; i < childCount; i++) {
    View child=getChildAt(i);
    if (child.getVisibility() == GONE) {
      continue;
    }
    int childHeightSpec=newHeightSpec;
    ViewGroup.LayoutParams layoutParams=child.getLayoutParams();
    if (layoutParams.height != ViewGroup.LayoutParams.MATCH_PARENT) {
      if (layoutParams.height >= 0) {
        childHeightSpec=layoutParams.height > ownMaxHeight && limitViewHeight ? MeasureSpec.makeMeasureSpec(ownMaxHeight,MeasureSpec.EXACTLY) : MeasureSpec.makeMeasureSpec(layoutParams.height,MeasureSpec.EXACTLY);
      }
      child.measure(getChildMeasureSpec(widthMeasureSpec,0,layoutParams.width),childHeightSpec);
      int childHeight=child.getMeasuredHeight();
      maxChildHeight=Math.max(maxChildHeight,childHeight);
    }
 else {
      mMatchParentViews.add(child);
    }
  }
  int ownHeight=hasFixedHeight ? ownMaxHeight : Math.min(ownMaxHeight,maxChildHeight);
  newHeightSpec=MeasureSpec.makeMeasureSpec(ownHeight,MeasureSpec.EXACTLY);
  for (  View child : mMatchParentViews) {
    child.measure(getChildMeasureSpec(widthMeasureSpec,0,child.getLayoutParams().width),newHeightSpec);
  }
  mMatchParentViews.clear();
  int width=MeasureSpec.getSize(widthMeasureSpec);
  setMeasuredDimension(width,ownHeight);
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  boolean limitViewHeight=shouldLimitViewHeight();
  final int givenSize=MeasureSpec.getSize(heightMeasureSpec);
  int ownMaxHeight=limitViewHeight ? mMaxViewHeight : Integer.MAX_VALUE;
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  boolean hasFixedHeight=heightMode == MeasureSpec.EXACTLY;
  if (hasFixedHeight) {
    ownMaxHeight=Math.min(givenSize,ownMaxHeight);
  }
  int newHeightSpec=MeasureSpec.makeMeasureSpec(ownMaxHeight,MeasureSpec.AT_MOST);
  int maxChildHeight=0;
  int childCount=getChildCount();
  for (int i=0; i < childCount; i++) {
    View child=getChildAt(i);
    if (child.getVisibility() == GONE) {
      continue;
    }
    int childHeightSpec=newHeightSpec;
    ViewGroup.LayoutParams layoutParams=child.getLayoutParams();
    if (layoutParams.height != ViewGroup.LayoutParams.MATCH_PARENT) {
      if (layoutParams.height >= 0) {
        childHeightSpec=layoutParams.height > ownMaxHeight && limitViewHeight ? MeasureSpec.makeMeasureSpec(ownMaxHeight,MeasureSpec.EXACTLY) : MeasureSpec.makeMeasureSpec(layoutParams.height,MeasureSpec.EXACTLY);
      }
      child.measure(getChildMeasureSpec(widthMeasureSpec,0,layoutParams.width),childHeightSpec);
      int childHeight=child.getMeasuredHeight();
      maxChildHeight=Math.max(maxChildHeight,childHeight);
    }
 else {
      mMatchParentViews.add(child);
    }
  }
  int ownHeight=hasFixedHeight ? ownMaxHeight : Math.min(ownMaxHeight,maxChildHeight);
  newHeightSpec=MeasureSpec.makeMeasureSpec(ownHeight,MeasureSpec.EXACTLY);
  for (  View child : mMatchParentViews) {
    child.measure(getChildMeasureSpec(widthMeasureSpec,0,child.getLayoutParams().width),newHeightSpec);
  }
  mMatchParentViews.clear();
  int width=MeasureSpec.getSize(widthMeasureSpec);
  setMeasuredDimension(width,ownHeight);
  mMeasuredTooHigh=heightMode != MeasureSpec.UNSPECIFIED && ownHeight > givenSize;
}