Bug 1236380 - GMPStorage::mShutdown=true until Init() succeeds - r?cpearce
Initialize GMPStorage::mShutdown to true, so that if Init() has not completed
yet or if it failed, other methods will not try and access a null mStorage.
--- a/dom/media/gmp/GMPStorageParent.cpp
+++ b/dom/media/gmp/GMPStorageParent.cpp
@@ -563,17 +563,17 @@ private:
nsClassHashtable<nsCStringHashKey, Record> mRecords;
};
GMPStorageParent::GMPStorageParent(const nsCString& aNodeId,
GMPParent* aPlugin)
: mNodeId(aNodeId)
, mPlugin(aPlugin)
- , mShutdown(false)
+ , mShutdown(true)
{
}
nsresult
GMPStorageParent::Init()
{
LOGD(("GMPStorageParent[%p]::Init()", this));
@@ -597,16 +597,17 @@ GMPStorageParent::Init()
NS_WARNING("Failed to initialize on disk GMP storage");
return NS_ERROR_FAILURE;
}
mStorage = Move(storage);
} else {
mStorage = MakeUnique<GMPMemoryStorage>();
}
+ mShutdown = false;
return NS_OK;
}
bool
GMPStorageParent::RecvOpen(const nsCString& aRecordName)
{
LOGD(("GMPStorageParent[%p]::RecvOpen(record='%s')",
this, aRecordName.get()));
--- a/dom/media/gmp/GMPStorageParent.h
+++ b/dom/media/gmp/GMPStorageParent.h
@@ -49,15 +49,16 @@ protected:
private:
~GMPStorageParent() {}
UniquePtr<GMPStorage> mStorage;
const nsCString mNodeId;
RefPtr<GMPParent> mPlugin;
+ // True after Shutdown(), or if Init() has not completed successfully.
bool mShutdown;
};
} // namespace gmp
} // namespace mozilla
#endif // GMPStorageParent_h_