Program: 28535
Project: 28535
Buggy source:
/** 
 * This block handles different drawables. Selector and LayerListDrawable are handled here. Override this to handle more types of drawables
 * @param view
 * @param attributeKey
 */
protected void handleElement(V view,String attributeKey,LayoutParser parser){
  String type=parser.getString(TYPE);
switch (type) {
case DRAWABLE_SELECTOR:
    final StateListDrawable stateListDrawable=new StateListDrawable();
  if (parser.isArray(CHILDREN)) {
    parser.peek(CHILDREN);
    while (parser.hasNext()) {
      parser.next();
      final Pair<int[],LayoutParser> state=ParseHelper.parseState(parser);
      if (state != null) {
        DrawableResourceProcessor<V> processor=new DrawableResourceProcessor<V>(){
          @Override public void setDrawable(          V view,          Drawable drawable){
            stateListDrawable.addState(state.first,drawable);
          }
        }
;
        processor.handle(view,attributeKey,state.second);
      }
    }
  }
setDrawable(view,stateListDrawable);
break;
case DRAWABLE_SHAPE:
GradientDrawable gradientDrawable=loadGradientDrawable(view.getContext(),parser);
if (null != gradientDrawable) {
setDrawable(view,gradientDrawable);
}
break;
case DRAWABLE_LAYER_LIST:
final List<Pair<Integer,Drawable>> drawables=new ArrayList<>();
if (parser.isArray(CHILDREN)) {
parser.peek(CHILDREN);
while (parser.hasNext()) {
parser.next();
final Pair<Integer,LayoutParser> layerPair=ParseHelper.parseLayer(parser);
if (null != layerPair) {
DrawableResourceProcessor<V> processor=new DrawableResourceProcessor<V>(){
@Override public void setDrawable(V view,Drawable drawable){
drawables.add(new Pair<>(layerPair.first,drawable));
onLayerDrawableFinish(view,drawables);
}
}
;
processor.handle(view,attributeKey,layerPair.second);
}
}
}
break;
case DRAWABLE_LEVEL_LIST:
final LevelListDrawable levelListDrawable=new LevelListDrawable();
if (parser.isArray(CHILDREN)) {
parser.peek(CHILDREN);
while (parser.hasNext()) {
parser.next();
}
}
break;
}
}

Fixed version (ground truth):
/** 
 * This block handles different drawables. Selector and LayerListDrawable are handled here. Override this to handle more types of drawables
 * @param view
 * @param attributeKey
 */
protected void handleElement(V view,String attributeKey,LayoutParser parser){
  String type=parser.getString(TYPE);
  LayoutParser children;
switch (type) {
case DRAWABLE_SELECTOR:
    final StateListDrawable stateListDrawable=new StateListDrawable();
  if (parser.isArray(CHILDREN)) {
    children=parser.peek(CHILDREN);
    while (children.hasNext()) {
      children.next();
      final Pair<int[],LayoutParser> state=ParseHelper.parseState(children);
      if (state != null) {
        DrawableResourceProcessor<V> processor=new DrawableResourceProcessor<V>(){
          @Override public void setDrawable(          V view,          Drawable drawable){
            stateListDrawable.addState(state.first,drawable);
          }
        }
;
        processor.handle(view,attributeKey,state.second);
      }
    }
  }
setDrawable(view,stateListDrawable);
break;
case DRAWABLE_SHAPE:
GradientDrawable gradientDrawable=loadGradientDrawable(view.getContext(),parser);
if (null != gradientDrawable) {
setDrawable(view,gradientDrawable);
}
break;
case DRAWABLE_LAYER_LIST:
final List<Pair<Integer,Drawable>> drawables=new ArrayList<>();
if (parser.isArray(CHILDREN)) {
children=parser.peek(CHILDREN);
while (children.hasNext()) {
children.next();
final Pair<Integer,LayoutParser> layerPair=ParseHelper.parseLayer(children);
if (null != layerPair) {
DrawableResourceProcessor<V> processor=new DrawableResourceProcessor<V>(){
@Override public void setDrawable(V view,Drawable drawable){
drawables.add(new Pair<>(layerPair.first,drawable));
onLayerDrawableFinish(view,drawables);
}
}
;
processor.handle(view,attributeKey,layerPair.second);
}
}
}
break;
case DRAWABLE_LEVEL_LIST:
final LevelListDrawable levelListDrawable=new LevelListDrawable();
if (parser.isArray(CHILDREN)) {
children=parser.peek(CHILDREN);
while (children.hasNext()) {
children.next();
}
}
break;
}
}