Program: 157331
Project: 157331
Buggy source:
/** 
 * Create a key with the given top-left coordinate and extract its attributes from the XML parser.
 * @param parent the row that this key belongs to. The row must alreadybe attached to a  {@link Keyboard}.
 * @param x      the x coordinate of the top-left
 * @param y      the y coordinate of the top-left
 * @param parser the XML parser containing the attributes for this key
 */
public Key(@NonNull AddOn.AddOnResourceMapping resourceMapping,Context askContext,Context keyboardContext,Row parent,KeyboardDimens keyboardDimens,int x,int y,XmlResourceParser parser){
  this(parent,keyboardDimens);
  final Resources askResources=askContext.getResources();
  this.x=x;
  this.y=y;
  width=Math.min(keyboardDimens.getKeyMaxWidth(),parent.defaultWidth);
  height=KeyboardSupport.getKeyHeightFromHeightCode(keyboardDimens,parent.defaultHeightCode,askResources.getConfiguration().orientation);
  gap=parent.defaultHorizontalGap;
  codes=new int[0];
  iconPreview=null;
  popupCharacters=null;
  popupResId=0;
  repeatable=false;
  showPreview=true;
  dynamicEmblem=KEY_EMBLEM_NONE;
  modifier=false;
  sticky=false;
  int[] remoteKeyboardLayoutStyleable=resourceMapping.getRemoteStyleableArrayFromLocal(R.styleable.KeyboardLayout);
  TypedArray a=keyboardContext.obtainStyledAttributes(Xml.asAttributeSet(parser),remoteKeyboardLayoutStyleable);
  int n=a.getIndexCount();
  for (int i=0; i < n; i++) {
    final int remoteIndex=a.getIndex(i);
    final int localAttrId=R.styleable.KeyboardLayout[remoteIndex];
    setDataFromTypedArray(parent,keyboardDimens,askResources,a,remoteIndex,localAttrId);
  }
  a.recycle();
  this.x+=gap;
  int[] remoteKeyboardKeyLayoutStyleable=resourceMapping.getRemoteStyleableArrayFromLocal(R.styleable.KeyboardLayout_Key);
  a=keyboardContext.obtainStyledAttributes(Xml.asAttributeSet(parser),remoteKeyboardKeyLayoutStyleable);
  n=a.getIndexCount();
  for (int i=0; i < n; i++) {
    final int remoteIndex=a.getIndex(i);
    final int localAttrId=R.styleable.KeyboardLayout_Key[remoteIndex];
    setDataFromTypedArray(parent,keyboardDimens,askResources,a,remoteIndex,localAttrId);
  }
  externalResourcePopupLayout=popupResId != 0;
  if (codes.length == 0 && !TextUtils.isEmpty(label)) {
    codes=new int[]{label.charAt(0)};
  }
  a.recycle();
}

Fixed version (ground truth):
/** 
 * Create a key with the given top-left coordinate and extract its attributes from the XML parser.
 * @param parent the row that this key belongs to. The row must alreadybe attached to a  {@link Keyboard}.
 * @param x      the x coordinate of the top-left
 * @param y      the y coordinate of the top-left
 * @param parser the XML parser containing the attributes for this key
 */
public Key(@NonNull AddOn.AddOnResourceMapping resourceMapping,Context askContext,Context keyboardContext,Row parent,KeyboardDimens keyboardDimens,int x,int y,XmlResourceParser parser){
  this(parent,keyboardDimens);
  final Resources askResources=askContext.getResources();
  this.x=x;
  this.y=y;
  width=Math.min(keyboardDimens.getKeyMaxWidth(),parent.defaultWidth);
  height=KeyboardSupport.getKeyHeightFromHeightCode(keyboardDimens,parent.defaultHeightCode,askResources.getConfiguration().orientation);
  gap=parent.defaultHorizontalGap;
  codes=new int[0];
  iconPreview=null;
  popupCharacters=null;
  popupResId=0;
  repeatable=false;
  showPreview=true;
  dynamicEmblem=KEY_EMBLEM_NONE;
  modifier=false;
  int[] remoteKeyboardLayoutStyleable=resourceMapping.getRemoteStyleableArrayFromLocal(R.styleable.KeyboardLayout);
  TypedArray a=keyboardContext.obtainStyledAttributes(Xml.asAttributeSet(parser),remoteKeyboardLayoutStyleable);
  int n=a.getIndexCount();
  for (int i=0; i < n; i++) {
    final int remoteIndex=a.getIndex(i);
    final int localAttrId=R.styleable.KeyboardLayout[remoteIndex];
    setDataFromTypedArray(parent,keyboardDimens,askResources,a,remoteIndex,localAttrId);
  }
  a.recycle();
  this.x+=gap;
  int[] remoteKeyboardKeyLayoutStyleable=resourceMapping.getRemoteStyleableArrayFromLocal(R.styleable.KeyboardLayout_Key);
  a=keyboardContext.obtainStyledAttributes(Xml.asAttributeSet(parser),remoteKeyboardKeyLayoutStyleable);
  n=a.getIndexCount();
  for (int i=0; i < n; i++) {
    final int remoteIndex=a.getIndex(i);
    final int localAttrId=R.styleable.KeyboardLayout_Key[remoteIndex];
    setDataFromTypedArray(parent,keyboardDimens,askResources,a,remoteIndex,localAttrId);
  }
  externalResourcePopupLayout=popupResId != 0;
  if (codes.length == 0 && !TextUtils.isEmpty(label)) {
    codes=new int[]{label.charAt(0)};
  }
  a.recycle();
}