Program: 157334
Project: 157334
Buggy source:
private void addPopupKeysToList(int baseKeyIndex,KeyboardDimens keyboardDimens,List<Key> keys,CharSequence popupCharacters,int characterOffset,int keysPerRow){
  int rowWidth=0;
  AnyKey baseKey=(AnyKey)keys.get(baseKeyIndex);
  Row row=baseKey.row;
  final float y=baseKey.y;
  final float keyHorizontalGap=row.defaultHorizontalGap;
  char popupCharacter=popupCharacters.charAt(characterOffset);
  baseKey.codes=new int[]{(int)popupCharacter};
  baseKey.label=Character.toString(popupCharacter);
  char upperCasePopupCharacter=Character.toUpperCase(popupCharacter);
  baseKey.shiftedCodes=new int[]{(int)upperCasePopupCharacter};
  baseKey.shiftedKeyLabel=Character.toString(upperCasePopupCharacter);
  float x=baseKey.width;
  AnyKey aKey=null;
  for (int popupCharIndex=characterOffset + 1; popupCharIndex < characterOffset + keysPerRow && popupCharIndex < popupCharacters.length(); popupCharIndex++) {
    x+=(keyHorizontalGap / 2);
    aKey=new AnyKey(row,keyboardDimens);
    popupCharacter=popupCharacters.charAt(popupCharIndex);
    aKey.codes=new int[]{(int)popupCharacter};
    aKey.label=Character.toString(popupCharacter);
    upperCasePopupCharacter=Character.toUpperCase(popupCharacter);
    aKey.shiftedCodes=new int[]{(int)upperCasePopupCharacter};
    aKey.shiftedKeyLabel=Character.toString(upperCasePopupCharacter);
    aKey.x=(int)x;
    aKey.width-=keyHorizontalGap;
    aKey.y=(int)y;
    final int xOffset=(int)(aKey.width + keyHorizontalGap + (keyHorizontalGap / 2));
    x+=xOffset;
    rowWidth+=xOffset;
    keys.add(baseKeyIndex,aKey);
  }
  baseKey.edgeFlags=EDGE_LEFT;
  if (aKey != null)   aKey.edgeFlags=EDGE_RIGHT;
 else   baseKey.edgeFlags|=EDGE_RIGHT;
  mAdditionalWidth=Math.max(rowWidth,mAdditionalWidth);
}

Fixed version (ground truth):
private void addPopupKeysToList(int baseKeyIndex,KeyboardDimens keyboardDimens,List<Key> keys,CharSequence popupCharacters,int characterOffset,int keysPerRow){
  int rowWidth=0;
  AnyKey baseKey=(AnyKey)keys.get(baseKeyIndex);
  Row row=baseKey.row;
  final float y=baseKey.y;
  final float keyHorizontalGap=row.defaultHorizontalGap;
  char popupCharacter=popupCharacters.charAt(characterOffset);
  baseKey.codes=new int[]{(int)popupCharacter};
  baseKey.label=Character.toString(popupCharacter);
  char upperCasePopupCharacter=Character.toUpperCase(popupCharacter);
  baseKey.shiftedCodes=new int[]{(int)upperCasePopupCharacter};
  float x=baseKey.width;
  AnyKey aKey=null;
  for (int popupCharIndex=characterOffset + 1; popupCharIndex < characterOffset + keysPerRow && popupCharIndex < popupCharacters.length(); popupCharIndex++) {
    x+=(keyHorizontalGap / 2);
    aKey=new AnyKey(row,keyboardDimens);
    popupCharacter=popupCharacters.charAt(popupCharIndex);
    aKey.codes=new int[]{(int)popupCharacter};
    aKey.label=Character.toString(popupCharacter);
    upperCasePopupCharacter=Character.toUpperCase(popupCharacter);
    aKey.shiftedCodes=new int[]{(int)upperCasePopupCharacter};
    aKey.x=(int)x;
    aKey.width-=keyHorizontalGap;
    aKey.y=(int)y;
    final int xOffset=(int)(aKey.width + keyHorizontalGap + (keyHorizontalGap / 2));
    x+=xOffset;
    rowWidth+=xOffset;
    keys.add(baseKeyIndex,aKey);
  }
  baseKey.edgeFlags=EDGE_LEFT;
  if (aKey != null)   aKey.edgeFlags=EDGE_RIGHT;
 else   baseKey.edgeFlags|=EDGE_RIGHT;
  mAdditionalWidth=Math.max(rowWidth,mAdditionalWidth);
}