refactor(ios): Migrate from PrivateSentrySDKOnly to SentrySDK.internal#6380
refactor(ios): Migrate from PrivateSentrySDKOnly to SentrySDK.internal#6380alwx wants to merge 3 commits into
No issues
find-bugs: Found 1 issue (1 low)
Low
UnsafeRawPointer escaped outside withUnsafePointer closure - `packages/core/ios/RNSentryInternal.swift:163-166`
In swizzleRNSScreenViewDidAppear, the UnsafeRawPointer produced inside withUnsafePointer(to: &rnsScreenViewDidAppearKey) { UnsafeRawPointer($0) } is returned from the closure and assigned to keyPtr, then used after the closure returns when passed to SentrySDK.internal.swizzle.instanceMethod(... key: keyPtr ...). Swift's API contract states the pointer argument is valid only for the duration of the closure body; escaping it is technically undefined behavior. In practice the pointer is only used as a stable identity token (never dereferenced) and rnsScreenViewDidAppearKey is a static var whose address is stable for the program lifetime, so real-world impact is negligible. To be spec-correct, take the address of the static property differently (e.g. UnsafeMutableRawPointer(&Self.rnsScreenViewDidAppearKey)) or perform the swizzle call inside the closure.
⏱ 13m 20s · 1.5M in / 118.3k out · $3.60