From 88a3dd68f5b31b14befee5a73de86d12bd415f90 Mon Sep 17 00:00:00 2001 From: Serg Date: Wed, 18 Feb 2026 00:59:01 -0500 Subject: [PATCH] Fix BodySnifferURLLoader::Cancel() crash on invalid WeakPtr dereference (#34003) Add a null check for throttle_ before dereferencing in Cancel(), consistent with existing guards in OnComplete() and CompleteSniffing(). Resolves: https://github.com/brave/brave-browser/issues/52931 --- components/body_sniffer/body_sniffer_url_loader.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/body_sniffer/body_sniffer_url_loader.cc b/components/body_sniffer/body_sniffer_url_loader.cc index c680b67e418..261ac78bfb6 100644 --- a/components/body_sniffer/body_sniffer_url_loader.cc +++ b/components/body_sniffer/body_sniffer_url_loader.cc @@ -450,6 +450,10 @@ void BodySnifferURLLoader::ForwardBodyToClient() { } void BodySnifferURLLoader::Cancel() { + if (!throttle_) { + Abort(); + return; + } throttle_->Cancel(); }