commit 2340085650ef52b6a7eae03b9a2e6d2e2e600515 parent ade6c59fd0fa3791eb27b4778d8edf0768731962 Author: Valentin Gosu <valentin.gosu@gmail.com> Date: Tue, 21 Oct 2025 12:36:33 +0000 Bug 1995068 - Avoid null pointer deref in EventSourceImpl::ReestablishConnection r=necko-reviewers,sunil Differential Revision: https://phabricator.services.mozilla.com/D269245 Diffstat:
| M | dom/base/EventSource.cpp | | | 10 | ++++++++-- |
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp @@ -1192,7 +1192,13 @@ void EventSourceImpl::ReestablishConnection() { return; } - rv = GetEventSource()->CheckCurrentGlobalCorrectness(); + RefPtr<EventSource> source = GetEventSource(); + if (!source) { + NS_WARNING("Event source is null"); + return; + } + + rv = source->CheckCurrentGlobalCorrectness(); if (NS_FAILED(rv)) { return; } @@ -1201,7 +1207,7 @@ void EventSourceImpl::ReestablishConnection() { ResetDecoder(); // We can't hold the mutex while dispatching the event because the mutex is // not reentrant, and content might call back into our code. - rv = GetEventSource()->CreateAndDispatchSimpleEvent(u"error"_ns); + rv = source->CreateAndDispatchSimpleEvent(u"error"_ns); if (NS_FAILED(rv)) { NS_WARNING("Failed to dispatch the error event!!!"); return;