Commit f2b6dbb8 authored by Feng Xiao's avatar Feng Xiao

Merge pull request #1162 from brian-peloton/master

Avoid upcasting uninitialized pointers
parents fe066bd5 96c2dd5d
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment