Program: 7963
Project: 7963
Buggy source:
@Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  if (scrollListener != null) {
    scrollListener.onScroll(view,firstVisibleItem,visibleItemCount,totalItemCount);
  }
  if (getAdapter() == null)   return;
  if (areHeadersSticky) {
    if (getChildCount() != 0) {
      if (lastWatchedViewHeader != null) {
        lastWatchedViewHeader.setVisibility(View.VISIBLE);
      }
      View viewToWatch=getChildAt(0);
      for (int i=1; i < getChildCount(); i++) {
        int firstChildDistance;
        if (clippingToPadding) {
          firstChildDistance=Math.abs((viewToWatch.getTop() - getPaddingTop()));
        }
 else {
          firstChildDistance=Math.abs(viewToWatch.getTop());
        }
        int secondChildDistance;
        if (clippingToPadding) {
          secondChildDistance=Math.abs((getChildAt(i).getTop() - getPaddingTop()) - headerHeight);
        }
 else {
          secondChildDistance=Math.abs(getChildAt(i).getTop() - headerHeight);
        }
        if (!(Boolean)viewToWatch.getTag() || ((Boolean)getChildAt(i).getTag() && secondChildDistance < firstChildDistance)) {
          viewToWatch=getChildAt(i);
        }
      }
      if ((Boolean)viewToWatch.getTag()) {
        if (headerHeight < 0)         headerHeight=viewToWatch.findViewById(R.id.header_view).getHeight();
        if (firstVisibleItem == 0 && getChildAt(0).getTop() > 0 && !clippingToPadding) {
          headerBottomPosition=0;
        }
 else {
          if (clippingToPadding) {
            headerBottomPosition=Math.min(viewToWatch.getTop(),headerHeight + getPaddingTop());
            headerBottomPosition=headerBottomPosition < getPaddingTop() ? headerHeight + getPaddingTop() : headerBottomPosition;
          }
 else {
            headerBottomPosition=Math.min(viewToWatch.getTop(),headerHeight);
            headerBottomPosition=headerBottomPosition < 0 ? headerHeight : headerBottomPosition;
          }
        }
        lastWatchedViewHeader=viewToWatch.findViewById(R.id.header_view);
        if (headerBottomPosition == (clippingToPadding ? headerHeight + getPaddingTop() : headerHeight) && viewToWatch.getTop() < (clippingToPadding ? headerHeight + getPaddingTop() : headerHeight)) {
          lastWatchedViewHeader.setVisibility(View.INVISIBLE);
        }
 else {
          lastWatchedViewHeader.setVisibility(View.VISIBLE);
        }
      }
 else {
        headerBottomPosition=headerHeight;
        if (clippingToPadding) {
          headerBottomPosition+=getPaddingTop();
        }
      }
    }
    if (Build.VERSION.SDK_INT < 11) {
      if (!clippingToPadding && getPaddingTop() > 0) {
        if (getChildAt(0).getTop() > 0) {
          if (firstVisibleItem > 0)           firstVisibleItem-=1;
        }
      }
    }
    if (oldHeaderId != ((StickyListHeadersAdapter)getAdapter()).getHeaderId(firstVisibleItem)) {
      headerHasChanged=true;
      header=((StickyListHeadersAdapter)getAdapter()).getHeaderView(firstVisibleItem,header);
      header.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,headerHeight));
    }
    oldHeaderId=((StickyListHeadersAdapter)getAdapter()).getHeaderId(firstVisibleItem);
  }
}

Fixed version (ground truth):
@Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  if (scrollListener != null) {
    scrollListener.onScroll(view,firstVisibleItem,visibleItemCount,totalItemCount);
  }
  if (getAdapter() == null || getAdapter().getCount() == 0)   return;
  if (areHeadersSticky) {
    if (getChildCount() != 0) {
      if (lastWatchedViewHeader != null) {
        lastWatchedViewHeader.setVisibility(View.VISIBLE);
      }
      View viewToWatch=getChildAt(0);
      for (int i=1; i < getChildCount(); i++) {
        int firstChildDistance;
        if (clippingToPadding) {
          firstChildDistance=Math.abs((viewToWatch.getTop() - getPaddingTop()));
        }
 else {
          firstChildDistance=Math.abs(viewToWatch.getTop());
        }
        int secondChildDistance;
        if (clippingToPadding) {
          secondChildDistance=Math.abs((getChildAt(i).getTop() - getPaddingTop()) - headerHeight);
        }
 else {
          secondChildDistance=Math.abs(getChildAt(i).getTop() - headerHeight);
        }
        if (!(Boolean)viewToWatch.getTag() || ((Boolean)getChildAt(i).getTag() && secondChildDistance < firstChildDistance)) {
          viewToWatch=getChildAt(i);
        }
      }
      if ((Boolean)viewToWatch.getTag()) {
        if (headerHeight < 0)         headerHeight=viewToWatch.findViewById(R.id.header_view).getHeight();
        if (firstVisibleItem == 0 && getChildAt(0).getTop() > 0 && !clippingToPadding) {
          headerBottomPosition=0;
        }
 else {
          if (clippingToPadding) {
            headerBottomPosition=Math.min(viewToWatch.getTop(),headerHeight + getPaddingTop());
            headerBottomPosition=headerBottomPosition < getPaddingTop() ? headerHeight + getPaddingTop() : headerBottomPosition;
          }
 else {
            headerBottomPosition=Math.min(viewToWatch.getTop(),headerHeight);
            headerBottomPosition=headerBottomPosition < 0 ? headerHeight : headerBottomPosition;
          }
        }
        lastWatchedViewHeader=viewToWatch.findViewById(R.id.header_view);
        if (headerBottomPosition == (clippingToPadding ? headerHeight + getPaddingTop() : headerHeight) && viewToWatch.getTop() < (clippingToPadding ? headerHeight + getPaddingTop() : headerHeight)) {
          lastWatchedViewHeader.setVisibility(View.INVISIBLE);
        }
 else {
          lastWatchedViewHeader.setVisibility(View.VISIBLE);
        }
      }
 else {
        headerBottomPosition=headerHeight;
        if (clippingToPadding) {
          headerBottomPosition+=getPaddingTop();
        }
      }
    }
    if (Build.VERSION.SDK_INT < 11) {
      if (!clippingToPadding && getPaddingTop() > 0) {
        if (getChildAt(0).getTop() > 0) {
          if (firstVisibleItem > 0)           firstVisibleItem-=1;
        }
      }
    }
    if (oldHeaderId != ((StickyListHeadersAdapter)getAdapter()).getHeaderId(firstVisibleItem)) {
      headerHasChanged=true;
      header=((StickyListHeadersAdapter)getAdapter()).getHeaderView(firstVisibleItem,header);
      header.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,headerHeight));
    }
    oldHeaderId=((StickyListHeadersAdapter)getAdapter()).getHeaderId(firstVisibleItem);
  }
}