Skip to content

[SaferCPP] Fix smart pointer fails in WKMockMediaDevice.cpp & WKMessageListener.cpp #47089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ UIProcess/API/C/WKGeolocationPermissionRequest.cpp
UIProcess/API/C/WKHTTPCookieStoreRef.cpp
UIProcess/API/C/WKInspector.cpp
UIProcess/API/C/WKMediaKeySystemPermissionCallback.cpp
UIProcess/API/C/WKMessageListener.cpp
UIProcess/API/C/WKMockMediaDevice.cpp
UIProcess/API/C/WKNotification.cpp
UIProcess/API/C/WKNotificationManager.cpp
UIProcess/API/C/WKNotificationPermissionRequest.cpp
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/API/C/WKMessageListener.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
* Copyright (C) 2019-2025 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -38,5 +38,5 @@ WKTypeID WKMessageListenerGetTypeID()

void WKMessageListenerSendReply(WKMessageListenerRef listenerRef, WKTypeRef value)
{
toImpl(listenerRef)->sendReply(toImpl(value));
toProtectedImpl(listenerRef)->sendReply(toImpl(value));
}
14 changes: 7 additions & 7 deletions Source/WebKit/UIProcess/API/C/WKMockMediaDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Apple Inc. All rights reserved.
* Copyright (C) 2018-2025 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -39,7 +39,7 @@ using namespace WebKit;
void WKAddMockMediaDevice(WKContextRef context, WKStringRef persistentId, WKStringRef label, WKStringRef type, WKDictionaryRef properties, bool isDefault)
{
#if ENABLE(MEDIA_STREAM)
String typeString = WebKit::toImpl(type)->string();
String typeString = WebKit::toProtectedImpl(type)->string();
Variant<WebCore::MockMicrophoneProperties, WebCore::MockSpeakerProperties, WebCore::MockCameraProperties, WebCore::MockDisplayProperties> deviceProperties;
if (typeString == "camera"_s) {
WebCore::MockCameraProperties cameraProperties;
Expand Down Expand Up @@ -72,26 +72,26 @@ void WKAddMockMediaDevice(WKContextRef context, WKStringRef persistentId, WKStri
}
}

toImpl(context)->addMockMediaDevice({ WebKit::toImpl(persistentId)->string(), WebKit::toImpl(label)->string(), flags, isDefault, WTFMove(deviceProperties) });
toProtectedImpl(context)->addMockMediaDevice({ WebKit::toProtectedImpl(persistentId)->string(), WebKit::toProtectedImpl(label)->string(), flags, isDefault, WTFMove(deviceProperties) });
#endif
}

void WKClearMockMediaDevices(WKContextRef context)
{
toImpl(context)->clearMockMediaDevices();
toProtectedImpl(context)->clearMockMediaDevices();
}

void WKRemoveMockMediaDevice(WKContextRef context, WKStringRef persistentId)
{
toImpl(context)->removeMockMediaDevice(WebKit::toImpl(persistentId)->string());
toProtectedImpl(context)->removeMockMediaDevice(WebKit::toProtectedImpl(persistentId)->string());
}

void WKResetMockMediaDevices(WKContextRef context)
{
toImpl(context)->resetMockMediaDevices();
toProtectedImpl(context)->resetMockMediaDevices();
}

void WKSetMockMediaDeviceIsEphemeral(WKContextRef context, WKStringRef persistentId, bool isEphemeral)
{
toImpl(context)->setMockMediaDeviceIsEphemeral(WebKit::toImpl(persistentId)->string(), isEphemeral);
toProtectedImpl(context)->setMockMediaDeviceIsEphemeral(WebKit::toProtectedImpl(persistentId)->string(), isEphemeral);
}