加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2020-26959.patch 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
wangxiao65 提交于 2021-01-07 15:15 . fix cves
# HG changeset patch
# User Luca Greco <lgreco@mozilla.com>
# Date 1603810809 0
# Tue Oct 27 15:00:09 2020 +0000
# Node ID 8de8cd3371e801d408650f102df04252c846f33d
# Parent 5058a78c1008f0917866aa09abff7430bcefa085
Bug 1669466 - Change WebRequestService singleton to a StaticRefPtr. r=glandium,mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D94692
diff -r 5058a78c1008 -r 8de8cd3371e8 toolkit/components/extensions/webrequest/WebRequestService.cpp
--- a/toolkit/components/extensions/webrequest/WebRequestService.cpp Tue Oct 27 15:07:07 2020 +0000
+++ b/toolkit/components/extensions/webrequest/WebRequestService.cpp Tue Oct 27 15:00:09 2020 +0000
@@ -13,22 +13,14 @@
using namespace mozilla::dom;
using namespace mozilla::extensions;
-static WebRequestService* sWeakWebRequestService;
-
-WebRequestService::~WebRequestService() { sWeakWebRequestService = nullptr; }
+static StaticRefPtr<WebRequestService> sWebRequestService;
/* static */ WebRequestService& WebRequestService::GetSingleton() {
- static RefPtr<WebRequestService> instance;
- if (!sWeakWebRequestService) {
- instance = new WebRequestService();
- ClearOnShutdown(&instance);
-
- // A separate weak instance that we keep a reference to as long as the
- // original service is alive, even after our strong reference is cleared to
- // allow the service to be destroyed.
- sWeakWebRequestService = instance;
+ if (!sWebRequestService) {
+ sWebRequestService = new WebRequestService();
+ ClearOnShutdown(&sWebRequestService);
}
- return *sWeakWebRequestService;
+ return *sWebRequestService;
}
UniquePtr<WebRequestChannelEntry> WebRequestService::RegisterChannel(
@@ -56,7 +48,7 @@
: mChannelId(aChannel->Id()), mChannel(aChannel) {}
WebRequestChannelEntry::~WebRequestChannelEntry() {
- if (sWeakWebRequestService) {
- sWeakWebRequestService->mChannelEntries.Remove(mChannelId);
+ if (sWebRequestService) {
+ sWebRequestService->mChannelEntries.Remove(mChannelId);
}
}
diff -r 5058a78c1008 -r 8de8cd3371e8 toolkit/components/extensions/webrequest/WebRequestService.h
--- a/toolkit/components/extensions/webrequest/WebRequestService.h Tue Oct 27 15:07:07 2020 +0000
+++ b/toolkit/components/extensions/webrequest/WebRequestService.h Tue Oct 27 15:00:09 2020 +0000
@@ -64,7 +64,7 @@
dom::ContentParent* aContentParent);
private:
- ~WebRequestService();
+ ~WebRequestService() = default;
friend ChannelEntry;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化