fix: use BlockedRequest struct to handle webRequest data (#42647)

Fixes an issue where Chromium could crash on a dangling unretained pointer in one of several webRequest functions. This was happening as a result of the fact that we had outstanding blocking requests continue to reference state owned by ProxyingWebsocket and ProxyingURLLoaderFactory after the requests were destroyed.

This had been going on for a few years, and was likely leading to some ongoing memory issues. To fix this, we need to ensure that all state is cleaned up in OnRequestWillBeDestroyed. I chose to create a new BlockedRequest struct to do so, which approximates the approach that upstream takes. The complexities of doing so also made our templated approach more trouble than it felt worth, so i pried that apart into separate handlers.
This commit is contained in:
Shelley Vohr 2024-07-02 14:02:49 +02:00 committed by GitHub
parent 8a8241163d
commit 1729a9868c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 304 additions and 111 deletions

View file

@ -328,7 +328,7 @@ describe('webRequest module', () => {
ses.webRequest.onBeforeSendHeaders((details, callback) => {
const requestHeaders = details.requestHeaders;
requestHeaders.Accept = '*/*;test/header';
callback({ requestHeaders: requestHeaders });
callback({ requestHeaders });
});
const { data } = await ajax('no-cors://fake-host/redirect');
expect(data).to.equal('header-received');
@ -341,7 +341,7 @@ describe('webRequest module', () => {
ses.webRequest.onBeforeSendHeaders((details, callback) => {
const requestHeaders = details.requestHeaders;
requestHeaders.Origin = 'http://new-origin';
callback({ requestHeaders: requestHeaders });
callback({ requestHeaders });
});
const { data } = await ajax(defaultURL);
expect(data).to.equal('/new/origin');