diff --git a/src/google/protobuf/stubs/statusor.h b/src/google/protobuf/stubs/statusor.h index a9d2b374b..ad848701b 100644 --- a/src/google/protobuf/stubs/statusor.h +++ b/src/google/protobuf/stubs/statusor.h @@ -224,14 +224,14 @@ inline StatusOr& StatusOr::operator=(const StatusOr& other) { template template inline StatusOr::StatusOr(const StatusOr& other) - : status_(other.status_), value_(other.value_) { + : status_(other.status_), value_(other.status_.ok() ? other.value_ : NULL) { } template template inline StatusOr& StatusOr::operator=(const StatusOr& other) { status_ = other.status_; - value_ = other.value_; + if (status_.ok()) value_ = other.value_; return *this; }