diff options
-rw-r--r-- | src/google/protobuf/stubs/statusor.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/google/protobuf/stubs/statusor.h b/src/google/protobuf/stubs/statusor.h index a9d2b374..ad848701 100644 --- a/src/google/protobuf/stubs/statusor.h +++ b/src/google/protobuf/stubs/statusor.h @@ -224,14 +224,14 @@ inline StatusOr<T>& StatusOr<T>::operator=(const StatusOr<T>& other) { template<typename T> template<typename U> inline StatusOr<T>::StatusOr(const StatusOr<U>& other) - : status_(other.status_), value_(other.value_) { + : status_(other.status_), value_(other.status_.ok() ? other.value_ : NULL) { } template<typename T> template<typename U> inline StatusOr<T>& StatusOr<T>::operator=(const StatusOr<U>& other) { status_ = other.status_; - value_ = other.value_; + if (status_.ok()) value_ = other.value_; return *this; } |