]> granicus.if.org Git - icu/commitdiff
ICU-12572 Fixing undefined behavior in NullableValue assignment operator.
authorShane Carr <shane@unicode.org>
Thu, 3 May 2018 09:26:15 +0000 (09:26 +0000)
committerShane Carr <shane@unicode.org>
Thu, 3 May 2018 09:26:15 +0000 (09:26 +0000)
X-SVN-Rev: 41318

icu4c/source/i18n/number_types.h

index 909302480f14566218ec3a0fcd5dd535c0887b24..57da72f8aa0ac1ffe122d761009a898a368636ed 100644 (file)
@@ -246,7 +246,13 @@ class U_I18N_API NullableValue {
         fNull = false;
     }
 
-    NullableValue<T>& operator=(const NullableValue<T>& other) = default;
+    NullableValue<T>& operator=(const NullableValue<T>& other) {
+        fNull = other.fNull;
+        if (!fNull) {
+            fValue = other.fValue;
+        }
+        return *this;
+    }
 
     NullableValue<T>& operator=(const T& other) {
         fValue = other;