Program: 87450
Project: 87450
Buggy source:
/** 
 * Add a new keystroke, with the pressed key's code point with the touch point coordinates.
 */
public void add(final int primaryCode,final int keyX,final int keyY){
  final int newIndex=size();
  if (mTransliterationMethod != null) {
    String c=new String(Character.toChars(primaryCode));
    int startPos=mTypedWord.length() > mTransliterationMethod.getMaxKeyLength() ? mTypedWord.length() - mTransliterationMethod.getMaxKeyLength() : 0;
    String input=mTypedWord.substring(startPos) + c;
    String replacement=mTransliterationMethod.transliterate(input,context,false);
    int divIndex=firstDivergence(input,replacement);
    replacement=replacement.substring(divIndex);
    mTypedWord.replace(startPos + divIndex,startPos + divIndex + replacement.length()+ 1,replacement);
    context+=c;
    if (context.length() > mTransliterationMethod.getContextLength()) {
      context=context.substring(context.length() - mTransliterationMethod.getContextLength());
    }
  }
 else {
    mTypedWord.appendCodePoint(primaryCode);
  }
  refreshSize();
  mCursorPositionWithinWord=mCodePointSize;
  if (newIndex < MAX_WORD_LENGTH) {
    mPrimaryKeyCodes[newIndex]=primaryCode >= Constants.CODE_SPACE ? Character.toLowerCase(primaryCode) : primaryCode;
    if (!mIsBatchMode) {
      mInputPointers.addPointer(newIndex,keyX,keyY,0,0);
    }
  }
  mIsFirstCharCapitalized=isFirstCharCapitalized(newIndex,primaryCode,mIsFirstCharCapitalized);
  if (Character.isUpperCase(primaryCode))   mCapsCount++;
  if (Character.isDigit(primaryCode))   mDigitsCount++;
  if (Constants.CODE_SINGLE_QUOTE == primaryCode) {
    ++mTrailingSingleQuotesCount;
  }
 else {
    mTrailingSingleQuotesCount=0;
  }
  mAutoCorrection=null;
}

Fixed version (ground truth):
/** 
 * Add a new keystroke, with the pressed key's code point with the touch point coordinates.
 */
public void add(final int primaryCode,final int keyX,final int keyY){
  final int newIndex=size();
  if (mTransliterationMethod != null) {
    String c=new String(Character.toChars(primaryCode));
    int startPos=mTypedWord.length() > mTransliterationMethod.getMaxKeyLength() ? mTypedWord.length() - mTransliterationMethod.getMaxKeyLength() : 0;
    String input=mTypedWord.substring(startPos) + c;
    String replacement=mTransliterationMethod.transliterate(input,context,false);
    int divIndex=firstDivergence(input,replacement);
    replacement=replacement.substring(divIndex);
    mTypedWord.replace(startPos + divIndex,startPos + divIndex + replacement.length()+ 2,replacement);
    context+=c;
    if (context.length() > mTransliterationMethod.getContextLength()) {
      context=context.substring(context.length() - mTransliterationMethod.getContextLength());
    }
  }
 else {
    mTypedWord.appendCodePoint(primaryCode);
  }
  refreshSize();
  mCursorPositionWithinWord=mCodePointSize;
  if (newIndex < MAX_WORD_LENGTH) {
    mPrimaryKeyCodes[newIndex]=primaryCode >= Constants.CODE_SPACE ? Character.toLowerCase(primaryCode) : primaryCode;
    if (!mIsBatchMode) {
      mInputPointers.addPointer(newIndex,keyX,keyY,0,0);
    }
  }
  mIsFirstCharCapitalized=isFirstCharCapitalized(newIndex,primaryCode,mIsFirstCharCapitalized);
  if (Character.isUpperCase(primaryCode))   mCapsCount++;
  if (Character.isDigit(primaryCode))   mDigitsCount++;
  if (Constants.CODE_SINGLE_QUOTE == primaryCode) {
    ++mTrailingSingleQuotesCount;
  }
 else {
    mTrailingSingleQuotesCount=0;
  }
  mAutoCorrection=null;
}