Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1846b8e3c9d7c722dcc5d5f3948f059ce7f08593
      
https://github.com/WebKit/WebKit/commit/1846b8e3c9d7c722dcc5d5f3948f059ce7f08593
  Author: Chris Dumez <[email protected]>
  Date:   2026-03-30 (Mon, 30 Mar 2026)

  Changed paths:
    M Source/WTF/wtf/darwin/TypeCastsOSObject.h
    M Tools/TestWebKitAPI/Tests/WTF/darwin/TypeCastsOSObjectCF.cpp
    M Tools/TestWebKitAPI/Tests/WTF/darwin/TypeCastsOSObjectCocoa.mm

  Log Message:
  -----------
  Fix wrong static_cast in lvalue dynamicOSObjectCast overloads and add test 
coverage
https://bugs.webkit.org/show_bug.cgi?id=311098

Reviewed by Darin Adler.

The lvalue (const OSObjectPtr<U>&) overloads of dynamicOSObjectCast used
static_cast<T*> instead of static_cast<T>. Since T is already a pointer type
(e.g. dispatch_queue_t = dispatch_queue_s*), T* produces a pointer-to-pointer,
which is incorrect. The rvalue overloads correctly used static_cast<T>.

The bug was latent because all existing callers used WTF::move() (hitting the
rvalue overload), and the existing tests only covered that path. Added tests
for dynamicOSObjectCast from const OSObjectPtr& in both the ObjC and C++ test
files to prevent regression.

Tests: Tools/TestWebKitAPI/Tests/WTF/darwin/TypeCastsOSObjectCF.cpp
       Tools/TestWebKitAPI/Tests/WTF/darwin/TypeCastsOSObjectCocoa.mm

* Source/WTF/wtf/darwin/TypeCastsOSObject.h:
(WTF::dynamicOSObjectCast):
* Tools/TestWebKitAPI/Tests/WTF/darwin/TypeCastsOSObjectCF.cpp:
(TestWebKitAPI::TEST(TypeCastsOSObjectCF, 
dynamicOSObjectCast_const_OSObjectPtr)):
* Tools/TestWebKitAPI/Tests/WTF/darwin/TypeCastsOSObjectCocoa.mm:
(TestWebKitAPI::TEST(TYPE_CASTS_OSOBJECT_PTR_TEST_NAME, 
dynamicOSObjectCast_from_OSObjectPtr)):
(TestWebKitAPI::TEST(TYPE_CASTS_OSOBJECT_PTR_TEST_NAME, 
dynamicOSObjectCast_from_const_OSObjectPtr)):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to