From 5c08151c227d98031abe27c3f0a8f43a7126ae9d Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 15 Sep 2011 15:42:21 +0900 Subject: [PATCH] Avoid returning an object that's still used internally There is no definite path known for this to end up being touched by other classes, but we could imagine through some way or some other it ends up shoved in the stringbuilder pool, leading to catastrophic results. Hopefully related to Bug: 5248688 Change-Id: Ib8abfc31263cbf31d515ed607ced5d8253971938 --- java/src/com/android/inputmethod/latin/Suggest.java | 6 ++---- java/src/com/android/inputmethod/latin/WordComposer.java | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 93933f1bc..16dccf824 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -306,12 +306,10 @@ public class Suggest implements Dictionary.WordCallback { Arrays.fill(mScores, 0); // Save a lowercase version of the original word - CharSequence typedWord = wordComposer.getTypedWord(); + String typedWord = wordComposer.getTypedWord(); if (typedWord != null) { - final String typedWordString = typedWord.toString(); - typedWord = typedWordString; // Treating USER_TYPED as UNIGRAM suggestion for logging now. - LatinImeLogger.onAddSuggestedWord(typedWordString, Suggest.DIC_USER_TYPED, + LatinImeLogger.onAddSuggestedWord(typedWord, Suggest.DIC_USER_TYPED, Dictionary.DataType.UNIGRAM); } mTypedWord = typedWord; diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 24519ad92..a79e6dc7f 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -164,11 +164,11 @@ public class WordComposer { * Returns the word as it was typed, without any correction applied. * @return the word that was typed so far */ - public CharSequence getTypedWord() { + public String getTypedWord() { if (size() == 0) { return null; } - return mTypedWord; + return mTypedWord.toString(); } /**