From 7e90359b1ac1dcb10322cca41c996a0f5b2379cb Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Wed, 28 Sep 2011 20:29:19 +0000 Subject: [PATCH] ICU-8268 null check of value previously dereferenced. A value is null-checked after it has already been dereferenced. If it was null, it would never get to the check because of NullPointerException. X-SVN-Rev: 30732 --- .../main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java | 3 +-- .../core/src/com/ibm/icu/text/RuleBasedBreakIterator.java | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java index 288aee6fdc8..246c42943d2 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java @@ -559,10 +559,9 @@ public final class ZoneMeta { */ static boolean parseCustomID(String id, int[] fields) { NumberFormat numberFormat = null; - String idUppercase = id.toUpperCase(Locale.ENGLISH); if (id != null && id.length() > kGMT_ID.length() && - idUppercase.startsWith(kGMT_ID)) { + id.toUpperCase(Locale.ENGLISH).startsWith(kGMT_ID)) { ParsePosition pos = new ParsePosition(kGMT_ID.length()); int sign = 1; int hour = 0; diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java index 18162abcd6c..2ce91a79742 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java @@ -1170,6 +1170,10 @@ public int getRuleStatusVec(int[] fillInArray) { private int handlePrevious(short stateTable[]) { + if (fText == null || stateTable == null) { + return 0; + } + int state; int category = 0; int mode; @@ -1182,10 +1186,6 @@ public int getRuleStatusVec(int[] fillInArray) { boolean lookAheadHardBreak = (stateTable[RBBIDataWrapper.FLAGS+1] & RBBIDataWrapper.RBBI_LOOKAHEAD_HARD_BREAK) != 0; - - if (fText == null || stateTable == null) { - return 0; - } // handlePrevious() never gets the rule status. // Flag the status as invalid; if the user ever asks for status, we will need // to back up, then re-find the break position using handleNext(), which does -- 2.40.0