From 4acdd3ad692affd09d4d722be689f302e94b17d0 Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Thu, 10 Jan 2013 15:07:51 -0800 Subject: [PATCH] [Rlog] Fix some potential NPEs Change-Id: I07b18b5db81784dca32683e5f208088181c5eed9 --- .../inputmethod/research/ResearchLogger.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 5c44af1f2..01b5bdda5 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -1202,7 +1202,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang public static void latinIME_swapSwapperAndSpace(final CharSequence originalCharacters, final String charactersAfterSwap) { final ResearchLogger researchLogger = getInstance(); - final LogUnit logUnit = researchLogger.mMainLogBuffer.peekLastLogUnit(); + final LogUnit logUnit; + if (researchLogger.mMainLogBuffer == null) { + logUnit = null; + } else { + logUnit = researchLogger.mMainLogBuffer.peekLastLogUnit(); + } if (logUnit != null) { researchLogger.enqueueEvent(logUnit, LOGSTATEMENT_LATINIME_SWAPSWAPPERANDSPACE, originalCharacters, charactersAfterSwap); @@ -1273,7 +1278,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang final String originallyTypedWord, final boolean isBatchMode) { final ResearchLogger researchLogger = getInstance(); // TODO: Verify that mCurrentLogUnit has been restored and contains the reverted word. - final LogUnit logUnit = researchLogger.mMainLogBuffer.peekLastLogUnit(); + final LogUnit logUnit; + if (researchLogger.mMainLogBuffer == null) { + logUnit = null; + } else { + logUnit = researchLogger.mMainLogBuffer.peekLastLogUnit(); + } if (originallyTypedWord.length() > 0 && hasLetters(originallyTypedWord)) { if (logUnit != null) { logUnit.setWord(originallyTypedWord);