Commit 4f6270ff authored by Gabriele Svelto's avatar Gabriele Svelto
Browse files

Bug 1851847 - Check that we really do have a document before creating a MIDI...

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

Differential Revision: https://phabricator.services.mozilla.com/D187989
parent f1fb0868
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -63,7 +63,16 @@ MIDIPort::~MIDIPort() {
}

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;
  nsresult rv = nsContentUtils::GetASCIIOrigin(uri, origin);
  if (NS_FAILED(rv)) {