Skip to content

Commit

Permalink
[M115 merge] Use &* instead of .get() for BrowserOrResourceContext's …
Browse files Browse the repository at this point in the history
…raw_ref

Using * is more secure, as get() does not check the pointer for
validity, whereas * does.

(cherry picked from commit 90c9a89)

Change-Id: I3ea99de76c68afe3358ddf0d263008129d3ad70f
Bug: 1444438, 1444204
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4591832
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1153662}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4609855
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/branch-heads/5790@{#711}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
Alex Moshchuk authored and Chromium LUCI CQ committed Jun 13, 2023
1 parent aa23556 commit 2c98134
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions content/public/browser/browser_or_resource_context.h
Expand Up @@ -50,15 +50,15 @@ class CONTENT_EXPORT BrowserOrResourceContext final {
// TODO(dcheng): Change this to return a ref.
BrowserContext* ToBrowserContext() const {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return &absl::get<raw_ref<BrowserContext>>(storage_).get();
return &*absl::get<raw_ref<BrowserContext>>(storage_);
}

// To be called only on the UI thread. Will CHECK() if `this` does not hold a
// `ResourceContext*`.
// TODO(dcheng): Change this to return a ref.
ResourceContext* ToResourceContext() const {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
return &absl::get<raw_ref<ResourceContext>>(storage_).get();
return &*absl::get<raw_ref<ResourceContext>>(storage_);
}

private:
Expand Down

0 comments on commit 2c98134

Please sign in to comment.