Program: 23293
Project: 23293
Buggy source:
/** 
 * Measures the height of the given range of children (inclusive) and returns the height with this ListView's padding and divider heights included. If maxHeight is provided, the measuring will stop when the current height reaches maxHeight.
 * @param widthMeasureSpec The width measure spec to be given to a child's{@link View#measure(int,int)}.
 * @param startPosition The position of the first child to be shown.
 * @param endPosition The (inclusive) position of the last child to beshown. Specify  {@link #NO_POSITION} if the last child should bethe last available child from the adapter.
 * @param maxHeight The maximum height that will be returned (if all thechildren don't fit in this value, this value will be returned).
 * @param disallowPartialChildPosition In general, whether the returnedheight should only contain entire children. This is more powerful--it is the first inclusive position at which partial children will not be allowed. Example: it looks nice to have at least 3 completely visible children, and in portrait this will most likely fit; but in landscape there could be times when even 2 children can not be completely shown, so a value of 2 (remember, inclusive) would be good (assuming startPosition is 0).
 * @return The height of this ListView with the given children.
 */
final int measureHeightOfChildren(int widthMeasureSpec,int startPosition,int endPosition,final int maxHeight,int disallowPartialChildPosition){
  final ListAdapter adapter=mAdapter;
  if (adapter == null) {
    return mListPadding.top + mListPadding.bottom;
  }
  int returnedHeight=mListPadding.top + mListPadding.bottom;
  final int dividerHeight=((mDividerHeight > 0) && mDivider != null) ? mDividerHeight : 0;
  int prevHeightWithoutPartialChild=0;
  int i;
  View child;
  endPosition=(endPosition == NO_POSITION) ? adapter.getCount() - 1 : endPosition;
  final AbsListView.RecycleBin recycleBin=mRecycler;
  final boolean recyle=recycleOnMeasure();
  for (i=startPosition; i <= endPosition; ++i) {
    child=obtainView(i);
    measureScrapChild(child,i,widthMeasureSpec);
    if (i > 0) {
      returnedHeight+=dividerHeight;
    }
    if (recyle) {
      recycleBin.addScrapView(child);
    }
    returnedHeight+=child.getMeasuredHeight();
    if (returnedHeight >= maxHeight) {
      return (disallowPartialChildPosition >= 0) && (i > disallowPartialChildPosition) && (prevHeightWithoutPartialChild > 0)&& (returnedHeight != maxHeight) ? prevHeightWithoutPartialChild : maxHeight;
    }
    if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) {
      prevHeightWithoutPartialChild=returnedHeight;
    }
  }
  return returnedHeight;
}

Fixed version (ground truth):
/** 
 * Measures the height of the given range of children (inclusive) and returns the height with this ListView's padding and divider heights included. If maxHeight is provided, the measuring will stop when the current height reaches maxHeight.
 * @param widthMeasureSpec The width measure spec to be given to a child's{@link View#measure(int,int)}.
 * @param startPosition The position of the first child to be shown.
 * @param endPosition The (inclusive) position of the last child to beshown. Specify  {@link #NO_POSITION} if the last child should bethe last available child from the adapter.
 * @param maxHeight The maximum height that will be returned (if all thechildren don't fit in this value, this value will be returned).
 * @param disallowPartialChildPosition In general, whether the returnedheight should only contain entire children. This is more powerful--it is the first inclusive position at which partial children will not be allowed. Example: it looks nice to have at least 3 completely visible children, and in portrait this will most likely fit; but in landscape there could be times when even 2 children can not be completely shown, so a value of 2 (remember, inclusive) would be good (assuming startPosition is 0).
 * @return The height of this ListView with the given children.
 */
final int measureHeightOfChildren(int widthMeasureSpec,int startPosition,int endPosition,final int maxHeight,int disallowPartialChildPosition){
  final ListAdapter adapter=mAdapter;
  if (adapter == null) {
    return mListPadding.top + mListPadding.bottom;
  }
  int returnedHeight=mListPadding.top + mListPadding.bottom;
  final int dividerHeight=((mDividerHeight > 0) && mDivider != null) ? mDividerHeight : 0;
  int prevHeightWithoutPartialChild=0;
  int i;
  View child;
  endPosition=(endPosition == NO_POSITION) ? adapter.getCount() - 1 : endPosition;
  final AbsListView.RecycleBin recycleBin=mRecycler;
  final boolean recyle=recycleOnMeasure();
  final boolean[] isScrap=mIsScrap;
  for (i=startPosition; i <= endPosition; ++i) {
    child=obtainView(i,isScrap);
    measureScrapChild(child,i,widthMeasureSpec);
    if (i > 0) {
      returnedHeight+=dividerHeight;
    }
    if (recyle) {
      recycleBin.addScrapView(child);
    }
    returnedHeight+=child.getMeasuredHeight();
    if (returnedHeight >= maxHeight) {
      return (disallowPartialChildPosition >= 0) && (i > disallowPartialChildPosition) && (prevHeightWithoutPartialChild > 0)&& (returnedHeight != maxHeight) ? prevHeightWithoutPartialChild : maxHeight;
    }
    if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) {
      prevHeightWithoutPartialChild=returnedHeight;
    }
  }
  return returnedHeight;
}