]> granicus.if.org Git - icu/commitdiff
ICU-8268 null check of value previously dereferenced.
authorAbhinav Gupta <mail@abhinavg.net>
Wed, 28 Sep 2011 20:29:19 +0000 (20:29 +0000)
committerAbhinav Gupta <mail@abhinavg.net>
Wed, 28 Sep 2011 20:29:19 +0000 (20:29 +0000)
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

icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java
icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java

index 288aee6fdc8e7ee0f1efaaf779902016d3e39981..246c42943d2d5d882a7e7e1a0ab6878cec6a20bc 100644 (file)
@@ -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;
index 18162abcd6c5598d02ce0850e7a34c4e4d3ab975..2ce91a79742a74bf3deb50a3056dc9f65febe3a3 100644 (file)
@@ -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