[MediaStream] Protect MediaDevicesRequest during callback
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 Dec 2016 22:08:05 +0000 (22:08 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 Dec 2016 22:08:05 +0000 (22:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165711
<rdar://problem/28400468>

Reviewed by Sam Weinig.

No new tests, I was unable to create a reproducible test but this fix avoids
an occasional crash in existing tests.

* Modules/mediastream/MediaDevicesEnumerationRequest.cpp:
(WebCore::MediaDevicesEnumerationRequest::start): Take a reference to the object
before calling the controller in case the completion handler is called synchronously.

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.cpp

index 3c8066a..e5861b0 100644 (file)
@@ -1,3 +1,18 @@
+2016-12-11  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] Protect MediaDevicesRequest during callback
+        https://bugs.webkit.org/show_bug.cgi?id=165711
+        <rdar://problem/28400468>
+
+        Reviewed by Sam Weinig.
+
+        No new tests, I was unable to create a reproducible test but this fix avoids
+        an occasional crash in existing tests.
+
+        * Modules/mediastream/MediaDevicesEnumerationRequest.cpp:
+        (WebCore::MediaDevicesEnumerationRequest::start): Take a reference to the object
+        before calling the controller in case the completion handler is called synchronously.
+
 2016-12-09  Filip Pizlo  <fpizlo@apple.com>
 
         The DOM should have an advancing wavefront opaque root barrier
 2016-12-09  Filip Pizlo  <fpizlo@apple.com>
 
         The DOM should have an advancing wavefront opaque root barrier
index 31a8275..1f1a947 100644 (file)
@@ -88,6 +88,7 @@ void MediaDevicesEnumerationRequest::start()
     if (!controller)
         return;
 
     if (!controller)
         return;
 
+    Ref<MediaDevicesEnumerationRequest> protectedThis(*this);
     controller->enumerateMediaDevices(*this);
 }
 
     controller->enumerateMediaDevices(*this);
 }