Bug 1406820 part 2. Fix some missing member initialization in dom/bindings code. r=qdot

This commit is contained in:
Jonathan Watt 2017-09-22 11:35:07 +01:00
parent 24b417787f
commit 84328b84e7
2 changed files with 8 additions and 6 deletions

View file

@ -345,18 +345,19 @@ template<>
class Optional<nsAString> class Optional<nsAString>
{ {
public: public:
Optional() : mPassed(false) {} Optional()
: mStr(nullptr)
{}
bool WasPassed() const bool WasPassed() const
{ {
return mPassed; return !!mStr;
} }
void operator=(const nsAString* str) void operator=(const nsAString* str)
{ {
MOZ_ASSERT(str); MOZ_ASSERT(str);
mStr = str; mStr = str;
mPassed = true;
} }
// If this code ever goes away, remove the comment pointing to it in the // If this code ever goes away, remove the comment pointing to it in the
@ -365,7 +366,6 @@ public:
{ {
MOZ_ASSERT(str); MOZ_ASSERT(str);
mStr = reinterpret_cast<const nsString*>(str); mStr = reinterpret_cast<const nsString*>(str);
mPassed = true;
} }
const nsAString& Value() const const nsAString& Value() const
@ -379,7 +379,6 @@ private:
Optional(const Optional& other) = delete; Optional(const Optional& other) = delete;
const Optional &operator=(const Optional &other) = delete; const Optional &operator=(const Optional &other) = delete;
bool mPassed;
const nsAString* mStr; const nsAString* mStr;
}; };
@ -388,8 +387,9 @@ class NonNull
{ {
public: public:
NonNull() NonNull()
: ptr(nullptr)
#ifdef DEBUG #ifdef DEBUG
: inited(false) , inited(false)
#endif #endif
{} {}

View file

@ -19,6 +19,8 @@ namespace binding_detail {
// for small strings and a nsStringBuffer for longer strings. // for small strings and a nsStringBuffer for longer strings.
struct FakeString { struct FakeString {
FakeString() : FakeString() :
mData(nsString::char_traits::sEmptyBuffer),
mLength(0),
mDataFlags(nsString::DataFlags::TERMINATED), mDataFlags(nsString::DataFlags::TERMINATED),
mClassFlags(nsString::ClassFlags(0)) mClassFlags(nsString::ClassFlags(0))
{ {