Program: 2643
Project: 2643
Buggy source:
/** 
 * Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.  Use null if you do not want a Drawable there.  The Drawables must already have had  {@link Drawable#setBounds} called.
 * @attr ref android.R.styleable#TextView_drawableStart
 * @attr ref android.R.styleable#TextView_drawableTop
 * @attr ref android.R.styleable#TextView_drawableEnd
 * @attr ref android.R.styleable#TextView_drawableBottom
 */
public void setCompoundDrawablesRelative(Drawable start,Drawable top,Drawable end,Drawable bottom){
  Drawables dr=mDrawables;
  final boolean drawables=start != null || top != null || end != null || bottom != null;
  if (!drawables) {
    if (dr != null) {
      if (dr.mDrawablePadding == 0) {
        mDrawables=null;
      }
 else {
        if (dr.mDrawableStart != null)         dr.mDrawableStart.setCallback(null);
        dr.mDrawableStart=null;
        if (dr.mDrawableTop != null)         dr.mDrawableTop.setCallback(null);
        dr.mDrawableTop=null;
        if (dr.mDrawableEnd != null)         dr.mDrawableEnd.setCallback(null);
        dr.mDrawableEnd=null;
        if (dr.mDrawableBottom != null)         dr.mDrawableBottom.setCallback(null);
        dr.mDrawableBottom=null;
        dr.mDrawableSizeStart=dr.mDrawableHeightStart=0;
        dr.mDrawableSizeEnd=dr.mDrawableHeightEnd=0;
        dr.mDrawableSizeTop=dr.mDrawableWidthTop=0;
        dr.mDrawableSizeBottom=dr.mDrawableWidthBottom=0;
      }
    }
  }
 else {
    if (dr == null) {
      mDrawables=dr=new Drawables();
    }
    if (dr.mDrawableStart != start && dr.mDrawableStart != null) {
      dr.mDrawableStart.setCallback(null);
    }
    dr.mDrawableStart=start;
    if (dr.mDrawableTop != top && dr.mDrawableTop != null) {
      dr.mDrawableTop.setCallback(null);
    }
    dr.mDrawableTop=top;
    if (dr.mDrawableEnd != end && dr.mDrawableEnd != null) {
      dr.mDrawableEnd.setCallback(null);
    }
    dr.mDrawableEnd=end;
    if (dr.mDrawableBottom != bottom && dr.mDrawableBottom != null) {
      dr.mDrawableBottom.setCallback(null);
    }
    dr.mDrawableBottom=bottom;
    final Rect compoundRect=dr.mCompoundRect;
    int[] state;
    state=getDrawableState();
    if (start != null) {
      start.setState(state);
      start.copyBounds(compoundRect);
      start.setCallback(this);
      dr.mDrawableSizeStart=compoundRect.width();
      dr.mDrawableHeightStart=compoundRect.height();
    }
 else {
      dr.mDrawableSizeStart=dr.mDrawableHeightStart=0;
    }
    if (end != null) {
      end.setState(state);
      end.copyBounds(compoundRect);
      end.setCallback(this);
      dr.mDrawableSizeEnd=compoundRect.width();
      dr.mDrawableHeightEnd=compoundRect.height();
    }
 else {
      dr.mDrawableSizeEnd=dr.mDrawableHeightEnd=0;
    }
    if (top != null) {
      top.setState(state);
      top.copyBounds(compoundRect);
      top.setCallback(this);
      dr.mDrawableSizeTop=compoundRect.height();
      dr.mDrawableWidthTop=compoundRect.width();
    }
 else {
      dr.mDrawableSizeTop=dr.mDrawableWidthTop=0;
    }
    if (bottom != null) {
      bottom.setState(state);
      bottom.copyBounds(compoundRect);
      bottom.setCallback(this);
      dr.mDrawableSizeBottom=compoundRect.height();
      dr.mDrawableWidthBottom=compoundRect.width();
    }
 else {
      dr.mDrawableSizeBottom=dr.mDrawableWidthBottom=0;
    }
  }
  resolveDrawables();
  invalidate();
  requestLayout();
}

Fixed version (ground truth):
/** 
 * Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.  Use null if you do not want a Drawable there.  The Drawables must already have had  {@link Drawable#setBounds} called.
 * @attr ref android.R.styleable#TextView_drawableStart
 * @attr ref android.R.styleable#TextView_drawableTop
 * @attr ref android.R.styleable#TextView_drawableEnd
 * @attr ref android.R.styleable#TextView_drawableBottom
 */
public void setCompoundDrawablesRelative(Drawable start,Drawable top,Drawable end,Drawable bottom){
  Drawables dr=mDrawables;
  final boolean drawables=start != null || top != null || end != null || bottom != null;
  if (!drawables) {
    if (dr != null) {
      if (dr.mDrawablePadding == 0) {
        mDrawables=null;
      }
 else {
        if (dr.mDrawableStart != null)         dr.mDrawableStart.setCallback(null);
        dr.mDrawableStart=null;
        if (dr.mDrawableTop != null)         dr.mDrawableTop.setCallback(null);
        dr.mDrawableTop=null;
        if (dr.mDrawableEnd != null)         dr.mDrawableEnd.setCallback(null);
        dr.mDrawableEnd=null;
        if (dr.mDrawableBottom != null)         dr.mDrawableBottom.setCallback(null);
        dr.mDrawableBottom=null;
        dr.mDrawableSizeStart=dr.mDrawableHeightStart=0;
        dr.mDrawableSizeEnd=dr.mDrawableHeightEnd=0;
        dr.mDrawableSizeTop=dr.mDrawableWidthTop=0;
        dr.mDrawableSizeBottom=dr.mDrawableWidthBottom=0;
      }
    }
  }
 else {
    if (dr == null) {
      mDrawables=dr=new Drawables(getContext());
    }
    mDrawables.mOverride=true;
    if (dr.mDrawableStart != start && dr.mDrawableStart != null) {
      dr.mDrawableStart.setCallback(null);
    }
    dr.mDrawableStart=start;
    if (dr.mDrawableTop != top && dr.mDrawableTop != null) {
      dr.mDrawableTop.setCallback(null);
    }
    dr.mDrawableTop=top;
    if (dr.mDrawableEnd != end && dr.mDrawableEnd != null) {
      dr.mDrawableEnd.setCallback(null);
    }
    dr.mDrawableEnd=end;
    if (dr.mDrawableBottom != bottom && dr.mDrawableBottom != null) {
      dr.mDrawableBottom.setCallback(null);
    }
    dr.mDrawableBottom=bottom;
    final Rect compoundRect=dr.mCompoundRect;
    int[] state;
    state=getDrawableState();
    if (start != null) {
      start.setState(state);
      start.copyBounds(compoundRect);
      start.setCallback(this);
      dr.mDrawableSizeStart=compoundRect.width();
      dr.mDrawableHeightStart=compoundRect.height();
    }
 else {
      dr.mDrawableSizeStart=dr.mDrawableHeightStart=0;
    }
    if (end != null) {
      end.setState(state);
      end.copyBounds(compoundRect);
      end.setCallback(this);
      dr.mDrawableSizeEnd=compoundRect.width();
      dr.mDrawableHeightEnd=compoundRect.height();
    }
 else {
      dr.mDrawableSizeEnd=dr.mDrawableHeightEnd=0;
    }
    if (top != null) {
      top.setState(state);
      top.copyBounds(compoundRect);
      top.setCallback(this);
      dr.mDrawableSizeTop=compoundRect.height();
      dr.mDrawableWidthTop=compoundRect.width();
    }
 else {
      dr.mDrawableSizeTop=dr.mDrawableWidthTop=0;
    }
    if (bottom != null) {
      bottom.setState(state);
      bottom.copyBounds(compoundRect);
      bottom.setCallback(this);
      dr.mDrawableSizeBottom=compoundRect.height();
      dr.mDrawableWidthBottom=compoundRect.width();
    }
 else {
      dr.mDrawableSizeBottom=dr.mDrawableWidthBottom=0;
    }
  }
  resetResolvedDrawables();
  resolveDrawables();
  invalidate();
  requestLayout();
}