WTR::InjectedBundlePage::willSendRequestForFrame() leaks a WKDataRef
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Feb 2019 19:32:31 +0000 (19:32 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Feb 2019 19:32:31 +0000 (19:32 +0000)
<https://webkit.org/b/194286>
<rdar://problem/47815558>

Reviewed by Alexey Proskuryakov.

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::willSendRequestForFrame): Use
WKRetainPtr<> to avoid leaking the WKDataRef.

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

Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

index 92f0303..bacdf01 100644 (file)
@@ -1,3 +1,15 @@
+2019-02-06  David Kilzer  <ddkilzer@apple.com>
+
+        WTR::InjectedBundlePage::willSendRequestForFrame() leaks a WKDataRef
+        <https://webkit.org/b/194286>
+        <rdar://problem/47815558>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::willSendRequestForFrame): Use
+        WKRetainPtr<> to avoid leaking the WKDataRef.
+
 2019-02-06  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, fix a typo
index f6ce494..5281d05 100644 (file)
@@ -1211,7 +1211,8 @@ WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef page
         String body = injectedBundle.testRunner()->willSendRequestHTTPBody();
         if (!body.isEmpty()) {
             CString cBody = body.utf8();
-            return WKURLRequestCopySettingHTTPBody(request, WKDataCreate(reinterpret_cast<const unsigned char*>(cBody.data()), cBody.length()));
+            WKRetainPtr<WKDataRef> body = adoptWK(WKDataCreate(reinterpret_cast<const unsigned char*>(cBody.data()), cBody.length()));
+            return WKURLRequestCopySettingHTTPBody(request, body.get());
         }
     }