]> granicus.if.org Git - icu/commitdiff
ICU-10976 Remove C++ null reference checks; they're undefined behavior.
authorAndy Heninger <andy.heninger@gmail.com>
Wed, 2 Jul 2014 20:57:26 +0000 (20:57 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Wed, 2 Jul 2014 20:57:26 +0000 (20:57 +0000)
X-SVN-Rev: 35987

icu4c/source/common/locid.cpp
icu4c/source/common/unistr.cpp
icu4c/source/i18n/msgfmt.cpp

index a0fa17d77c2d3b28d5461d903f935c4c9a4787f8..c98eb6c21eba203bd6998d487bc206be60955652 100644 (file)
@@ -422,11 +422,6 @@ Locale &Locale::operator=(const Locale &other)
         return *this;
     }
 
-    if (&other == NULL) {
-        this->setToBogus();
-        return *this;
-    }
-
     /* Free our current storage */
     if(fullName != fullNameBuffer) {
         uprv_free(fullName);
index a21c1b4a26571f3e3ecc9fa69bd92b0a53d6ec88..f103e816835a8453f21fff84ead68b38f3228ba5 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ******************************************************************************
-* Copyright (C) 1999-2013, International Business Machines Corporation and
+* Copyright (C) 1999-2014, International Business Machines Corporation and
 * others. All Rights Reserved.
 ******************************************************************************
 *
@@ -459,12 +459,12 @@ UnicodeString::fastCopyFrom(const UnicodeString &src) {
 UnicodeString &
 UnicodeString::copyFrom(const UnicodeString &src, UBool fastCopy) {
   // if assigning to ourselves, do nothing
-  if(this == 0 || this == &src) {
+  if(this == &src) {
     return *this;
   }
 
   // is the right side bogus?
-  if(&src == 0 || src.isBogus()) {
+  if(src.isBogus()) {
     setToBogus();
     return *this;
   }
index f9b353fcbe114a6393b549bb40cd168d27d382cc..853a64ca4ba932fbd643570f5895b9df0f96c369 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************
  *
@@ -786,16 +786,12 @@ MessageFormat::setFormat(const UnicodeString& formatName,
         (partIndex = nextTopLevelArgStart(partIndex)) >= 0 && U_SUCCESS(status);
     ) {
         if (argNameMatches(partIndex + 1, formatName, argNumber)) {
-            if (&newFormat == NULL) {
-                setCustomArgStartFormat(partIndex, NULL, status);
-            } else {
-                Format* new_format = newFormat.clone();
-                if (new_format == NULL) {
-                    status = U_MEMORY_ALLOCATION_ERROR;
-                    return;
-                }
-                setCustomArgStartFormat(partIndex, new_format, status);
+            Format* new_format = newFormat.clone();
+            if (new_format == NULL) {
+                status = U_MEMORY_ALLOCATION_ERROR;
+                return;
             }
+            setCustomArgStartFormat(partIndex, new_format, status);
         }
     }
 }