Bug 1851847 - Check that we really do have a document before creating a MIDI port r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D187989
This commit is contained in:
Gabriele Svelto 2023-09-15 10:08:47 +00:00
parent 0a1616968d
commit fccf853420

View File

@ -63,7 +63,16 @@ MIDIPort::~MIDIPort() {
} }
bool MIDIPort::Initialize(const MIDIPortInfo& aPortInfo, bool aSysexEnabled) { bool MIDIPort::Initialize(const MIDIPortInfo& aPortInfo, bool aSysexEnabled) {
nsIURI* uri = GetDocumentIfCurrent()->GetDocumentURI(); nsCOMPtr<Document> document = GetDocumentIfCurrent();
if (!document) {
return false;
}
nsCOMPtr<nsIURI> uri = document->GetDocumentURI();
if (!uri) {
return false;
}
nsAutoCString origin; nsAutoCString origin;
nsresult rv = nsContentUtils::GetWebExposedOriginSerialization(uri, origin); nsresult rv = nsContentUtils::GetWebExposedOriginSerialization(uri, origin);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {