Program: 157398
Project: 157398
Buggy source:
/** 
 * Returns a list of words that match the list of character codes passed in. This list will be overwritten the next time this function is called.
 * @return list of suggestions.
 */
public List<CharSequence> getSuggestions(WordComposer wordComposer,boolean includeTypedWordIfValid){
  mExplodedAbbreviations.clear();
  mHaveCorrection=false;
  mIsFirstCharCapitalized=wordComposer.isFirstCharCapitalized();
  mIsAllUpperCase=wordComposer.isAllUpperCase();
  collectGarbage();
  Arrays.fill(mPriorities,0);
  mOriginalWord=wordComposer.getTypedWord();
  if (mOriginalWord.length() > 0) {
    mOriginalWord=mOriginalWord.toString();
    mLowerOriginalWord=mOriginalWord.toString().toLowerCase(mLocale);
  }
 else {
    mLowerOriginalWord="String_Node_Str";
  }
  if (wordComposer.length() >= mMinimumWordSizeToStartCorrecting) {
    if (mContactsDictionary != null) {
      mContactsDictionary.getWords(wordComposer,this);
    }
    if (mUserDictionary != null) {
      mUserDictionary.getWords(wordComposer,this);
    }
    if (mSuggestions.size() > 0 && isValidWord(mOriginalWord)) {
      mHaveCorrection=true;
    }
    if (mMainDict != null) {
      mMainDict.getWords(wordComposer,this);
    }
    if (mAutoTextEnabled && mAbbreviationDictionary != null) {
      mAbbreviationDictionary.getWords(wordComposer,this);
    }
    if (mSuggestions.size() > 0) {
      mHaveCorrection=true;
    }
    if (mOriginalWord != null) {
      mSuggestions.add(0,mOriginalWord.toString());
    }
    if (mExplodedAbbreviations.size() > 0) {
      for (      String explodedWord : mExplodedAbbreviations)       mSuggestions.add(1,explodedWord);
      mHaveCorrection=true;
    }
  }
  if (mMainDictionaryEnabled && mSuggestions.size() > 1 && mExplodedAbbreviations.size() == 0) {
    if (!haveSufficientCommonality(mLowerOriginalWord,mSuggestions.get(1))) {
      mHaveCorrection=false;
    }
  }
  if (mLowerOriginalWord.length() > 0) {
    CharSequence autoText=mAutoTextEnabled && mAutoText != null ? mAutoText.lookup(mLowerOriginalWord,0,mLowerOriginalWord.length()) : null;
    boolean canAdd=(!TextUtils.isEmpty(autoText)) && (!TextUtils.equals(autoText,mOriginalWord));
    if (canAdd) {
      mHaveCorrection=true;
      if (mSuggestions.size() == 0) {
        mSuggestions.add(mOriginalWord);
      }
      mSuggestions.add(1,autoText);
    }
  }
  final int maxSearch=Math.min(5,mSuggestions.size());
  for (int suggestionIndex=1; suggestionIndex < maxSearch; suggestionIndex++) {
    if (TextUtils.equals(mOriginalWord,mSuggestions.get(suggestionIndex))) {
      mSuggestions.remove(suggestionIndex);
    }
  }
  return mSuggestions;
}

Fixed version (ground truth):
/** 
 * Returns a list of words that match the list of character codes passed in. This list will be overwritten the next time this function is called.
 * @return list of suggestions.
 */
public List<CharSequence> getSuggestions(WordComposer wordComposer,boolean includeTypedWordIfValid){
  mExplodedAbbreviations.clear();
  mHaveCorrection=false;
  mIsFirstCharCapitalized=wordComposer.isFirstCharCapitalized();
  mIsAllUpperCase=wordComposer.isAllUpperCase();
  collectGarbage();
  Arrays.fill(mPriorities,0);
  mOriginalWord=wordComposer.getTypedWord();
  if (mOriginalWord.length() > 0) {
    mOriginalWord=mOriginalWord.toString();
    mLowerOriginalWord=mOriginalWord.toString().toLowerCase(mLocale);
  }
 else {
    mLowerOriginalWord="String_Node_Str";
  }
  if (wordComposer.length() >= mMinimumWordSizeToStartCorrecting) {
    if (mContactsDictionary != null) {
      mContactsDictionary.getWords(wordComposer,this);
    }
    if (mUserDictionary != null) {
      mUserDictionary.getWords(wordComposer,this);
    }
    if (mSuggestions.size() > 0 && isValidWord(mOriginalWord)) {
      mHaveCorrection=true;
    }
    if (mMainDict != null) {
      mMainDict.getWords(wordComposer,this);
    }
    if (mAutoTextEnabled && mAbbreviationDictionary != null) {
      mAbbreviationDictionary.getWords(wordComposer,this);
    }
    if (mSuggestions.size() > 0) {
      mHaveCorrection=true;
    }
    if (mOriginalWord != null) {
      mSuggestions.add(0,mOriginalWord.toString());
    }
    if (mExplodedAbbreviations.size() > 0) {
      for (      String explodedWord : mExplodedAbbreviations)       mSuggestions.add(1,explodedWord);
      mHaveCorrection=true;
    }
  }
  if (mMainDictionaryEnabled && mSuggestions.size() > 1 && mExplodedAbbreviations.size() == 0) {
    if (!haveSufficientCommonality(mLowerOriginalWord,mSuggestions.get(1))) {
      mHaveCorrection=false;
    }
  }
  if (mLowerOriginalWord.length() > 0) {
    CharSequence autoText=mAutoTextEnabled && mAutoText != null ? mAutoText.lookup(mLowerOriginalWord,0,mLowerOriginalWord.length()) : null;
    boolean canAdd=(!TextUtils.isEmpty(autoText)) && (!TextUtils.equals(autoText,mOriginalWord));
    if (canAdd) {
      mHaveCorrection=true;
      if (mSuggestions.size() == 0) {
        mSuggestions.add(mOriginalWord);
      }
      mSuggestions.add(1,autoText);
    }
  }
  int maxSearchIndex=Math.min(5,mSuggestions.size());
  for (int suggestionIndex=1; suggestionIndex < maxSearchIndex; suggestionIndex++) {
    if (TextUtils.equals(mOriginalWord,mSuggestions.get(suggestionIndex))) {
      mSuggestions.remove(suggestionIndex);
      maxSearchIndex--;
    }
  }
  return mSuggestions;
}