MockLibWebRTCPeerConnection is leaking some session description
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2019 21:49:36 +0000 (21:49 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2019 21:49:36 +0000 (21:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195315
<rdar://problem/47840038>

Reviewed by David Kilzer.

Make sure to release raw pointers given from WebCore to mock libwebrtc layer.
Covered by existing tests when run in leaks mode.

* testing/MockLibWebRTCPeerConnection.cpp:
(WebCore::MockLibWebRTCPeerConnection::SetLocalDescription):
(WebCore::MockLibWebRTCPeerConnection::SetRemoteDescription):

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

Source/WebCore/ChangeLog
Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp

index ee7b9f4..8ef10b2 100644 (file)
@@ -1,3 +1,18 @@
+2019-03-05  Youenn Fablet  <youenn@apple.com>
+
+        MockLibWebRTCPeerConnection is leaking some session description
+        https://bugs.webkit.org/show_bug.cgi?id=195315
+        <rdar://problem/47840038>
+
+        Reviewed by David Kilzer.
+
+        Make sure to release raw pointers given from WebCore to mock libwebrtc layer.
+        Covered by existing tests when run in leaks mode.
+
+        * testing/MockLibWebRTCPeerConnection.cpp:
+        (WebCore::MockLibWebRTCPeerConnection::SetLocalDescription):
+        (WebCore::MockLibWebRTCPeerConnection::SetRemoteDescription):
+
 2019-03-05  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r242403.
index 2192b93..c0c0cbf 100644 (file)
@@ -164,7 +164,11 @@ public:
     virtual ~MockLibWebRTCPeerConnectionReleasedInNetworkThreadWhileSettingDescription() = default;
 
 private:
-    void SetLocalDescription(webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface*) final { releaseInNetworkThread(*this, *observer); }
+    void SetLocalDescription(webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface* sessionDescription) final
+    {
+        std::unique_ptr<webrtc::SessionDescriptionInterface> toBeFreed(sessionDescription);
+        releaseInNetworkThread(*this, *observer);
+    }
 };
 
 MockLibWebRTCPeerConnectionFactory::MockLibWebRTCPeerConnectionFactory(const String& testCase)
@@ -207,8 +211,9 @@ rtc::scoped_refptr<webrtc::MediaStreamInterface> MockLibWebRTCPeerConnectionFact
     return new rtc::RefCountedObject<webrtc::MediaStream>(label);
 }
 
-void MockLibWebRTCPeerConnection::SetLocalDescription(webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface*)
+void MockLibWebRTCPeerConnection::SetLocalDescription(webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface* sessionDescription)
 {
+    std::unique_ptr<webrtc::SessionDescriptionInterface> toBeFreed(sessionDescription);
     LibWebRTCProvider::callOnWebRTCSignalingThread([this, observer] {
         observer->OnSuccess();
         gotLocalDescription();
@@ -217,6 +222,7 @@ void MockLibWebRTCPeerConnection::SetLocalDescription(webrtc::SetSessionDescript
 
 void MockLibWebRTCPeerConnection::SetRemoteDescription(webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface* sessionDescription)
 {
+    std::unique_ptr<webrtc::SessionDescriptionInterface> toBeFreed(sessionDescription);
     LibWebRTCProvider::callOnWebRTCSignalingThread([observer] {
         observer->OnSuccess();
     });