[webkit-changes] [WebKit/WebKit] 6fe0ea: Add missing null check in ThreadSafeWeakPtr

Alex Christensen noreply at github.com
Thu Dec 8 16:24:15 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6fe0ea88b0e9257ead770bc0a99f531ef9cfd1f6
      https://github.com/WebKit/WebKit/commit/6fe0ea88b0e9257ead770bc0a99f531ef9cfd1f6
  Author: Alex Christensen <achristensen at apple.com>
  Date:   2022-12-08 (Thu, 08 Dec 2022)

  Changed paths:
    M Source/WTF/wtf/ThreadSafeWeakPtr.h
    M Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm
    M Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp

  Log Message:
  -----------
  Add missing null check in ThreadSafeWeakPtr
https://bugs.webkit.org/show_bug.cgi?id=248977
rdar://103044234

Reviewed by Chris Dumez.

When a ThreadSafeWeakPtr is used after it is moved, we still want ThreadSafeWeakPtr::get
to return null instead of dereferencing null.  I added a missing null check there.

I also made ThreadSafeWeakPtrControlBlock store a void* instead of a T* to avoid an unnecessary
reinterpret_cast, which I got feedback indicating that was scary.

I also make ProcessLauncher::launchProcess a little safer by removing the assumption that the
block passed to xpc_connection_set_event_handler would only be called once in case of error.
That assumption turned out to not be true in some exotic cases, which caused this investigation
in the first place.

* Source/WTF/wtf/ThreadSafeWeakPtr.h:
(WTF::ThreadSafeWeakPtrControlBlock::strongDeref const):
(WTF::ThreadSafeWeakPtrControlBlock::makeStrongReferenceIfPossible const):
(WTF::ThreadSafeWeakPtrControlBlock::ThreadSafeWeakPtrControlBlock):
(WTF::ThreadSafeWeakPtrControlBlock::WTF_GUARDED_BY_LOCK):
(WTF::ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr::deref const):
(WTF::ThreadSafeWeakPtr::get const):
(WTF::ThreadSafeWeakPtr::controlBlock):
(WTF::ThreadSafeWeakPtr::ThreadSafeWeakPtr):
* Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm:
(WebKit::ProcessLauncher::launchProcess):
* Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/257598@main




More information about the webkit-changes mailing list