From e42e505d865331fe1641e0a8d8ed07268a0a535e Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 12 May 2026 09:57:56 +0200 Subject: [PATCH] [DOM] Add nullcheck on document for requestSubmit --- dom/html/HTMLFormElement.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index a5f2442489..241d536d3b 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -305,7 +305,12 @@ HTMLFormElement::RequestSubmit(nsGenericHTMLElement* aSubmitter, InternalFormEvent event(true, eFormSubmit); event.mOriginator = aSubmitter; nsEventStatus status = nsEventStatus_eIgnore; - nsCOMPtr presShell = GetComposedDoc()->GetShell(); + nsCOMPtr document = GetComposedDoc(); + if (MOZ_UNLIKELY(!document)) { + aRv.Throw(NS_ERROR_DOM_NOT_FOUND_ERR); + return; + } + nsCOMPtr presShell = document->GetShell(); if (MOZ_LIKELY(presShell)) { presShell->HandleDOMEventWithTarget(this, &event, &status); }