Protect UserMediaRequest when stopping it
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2019 23:10:01 +0000 (23:10 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2019 23:10:01 +0000 (23:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201687
<rdar://problem/55241215>

Reviewed by Eric Carlson.

By removing the request from the map, we may destroy the request.
To make sure it stays alive, take the request from the map.

* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::cancelUserMediaRequest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249785 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp

index 71ffed0..b03d2e6 100644 (file)
@@ -1,3 +1,17 @@
+2019-09-11  Youenn Fablet  <youenn@apple.com>
+
+        Protect UserMediaRequest when stopping it
+        https://bugs.webkit.org/show_bug.cgi?id=201687
+        <rdar://problem/55241215>
+
+        Reviewed by Eric Carlson.
+
+        By removing the request from the map, we may destroy the request.
+        To make sure it stays alive, take the request from the map.
+
+        * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
+        (WebKit::UserMediaPermissionRequestManager::cancelUserMediaRequest):
+
 2019-09-11  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r249768.
index 8b3c6de..f78e2ef 100644 (file)
@@ -98,7 +98,8 @@ void UserMediaPermissionRequestManager::cancelUserMediaRequest(UserMediaRequest&
         return;
 
     request.deny(UserMediaRequest::OtherFailure, emptyString());
-    m_idToUserMediaRequestMap.remove(requestID);
+    auto removedRequest = m_idToUserMediaRequestMap.take(requestID);
+    ASSERT(removedRequest.get() == &request);
     removeMediaRequestFromMaps(request);
 }