Bug 312296

Summary: WebKitTestRunner leaks WKTypeRef out-parameter value from WKBundlePagePostSynchronousMessageForTesting()
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: Tools / TestsAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

David Kilzer (:ddkilzer)
Reported 2026-04-14 12:00:55 PDT
Several functions in `InjectedBundle.cpp` leak the retained `WKTypeRef` returned via the out-parameter of `WKBundlePagePostSynchronousMessageForTesting()`. The out-parameter returns a +1 retained object (via `toAPILeakingRef()`), but these callers never adopt or release it. Two patterns are affected: 1. `shouldForceRepaint()` and `isPrinting()` pass the raw `WKTypeRef` to `booleanValue()` without ever releasing it, leaking an `API::Boolean` object (visible as `WKNSNumber` in leak reports). 2. `getBackgroundFetchIdentifier()`, `lastAddedBackgroundFetchIdentifier()`, `lastRemovedBackgroundFetchIdentifier()`, `lastUpdatedBackgroundFetchIdentifier()`, and `backgroundFetchState()` return `static_cast<WKStringRef>(result)` into a `WKRetainPtr<WKStringRef>`. The `WKRetainPtr` constructor retains the pointer again without adopting the existing +1, so the original ownership is never balanced. Other callers in the same file (`shouldProcessWorkQueue()`, `isGeolocationClientActive()`, `imageCountInGeneralPasteboard()`, `userMediaPermissionRequestCount()`) already use `adoptWK(result).get()` correctly.
Attachments
Radar WebKit Bug Importer
Comment 1 2026-04-14 12:09:29 PDT
David Kilzer (:ddkilzer)
Comment 2 2026-04-14 12:12:17 PDT
EWS
Comment 3 2026-04-15 21:39:16 PDT
Committed 311347@main (112967a3c973): <https://commits.webkit.org/311347@main> Reviewed commits have been landed. Closing PR #62757 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.