Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent UB if a WeakPtr to an already-destroyed object is dereferenced.
If a WeakPtr references an already-destroyed object, operator-> and operator* end up simply dereferencing nullptr. However, dereferencing nullptr is undefined behavior and can be optimized in surprising ways by compilers. To prevent this from happening, add a defence of last resort and CHECK that the WeakPtr is still valid. (cherry picked from commit 0b308a0) Bug: 817982 Change-Id: Ib3a025c18fbd9d5db88770fced2063135086847b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463857 Commit-Queue: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Wez <wez@chromium.org> Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#816701} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2524521 Reviewed-by: Adrian Taylor <adetaylor@chromium.org> Reviewed-by: Krishna Govind <govind@chromium.org> Commit-Queue: Krishna Govind <govind@chromium.org> Commit-Queue: Adrian Taylor <adetaylor@chromium.org> Cr-Commit-Position: refs/branch-heads/4240@{#1410} Cr-Branched-From: f297677-refs/heads/master@{#800218}
- Loading branch information