REGRESSION (r15133): Fix leak of JSStringRef in minidom
<https://webkit.org/b/197968>
<rdar://problem/50872430>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

* API/tests/minidom.c:
(print): Call JSStringRelease() to fix the leak.

Tools:

* TestWebKitAPI/Tests/WebKitObjC/UserContentTest.mm:
(expectScriptValueIsString): Drive-by fix to use adopt() instead
of JSRetainPtr<JSStringRef> string(Adopt, JSValueToStringCopy(...)).


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245430 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/API/tests/minidom.c b/Source/JavaScriptCore/API/tests/minidom.c
index 41f18cd..6ebb399 100644
--- a/Source/JavaScriptCore/API/tests/minidom.c
+++ b/Source/JavaScriptCore/API/tests/minidom.c
@@ -91,6 +91,7 @@
         char stringUTF8[numChars];
         JSStringGetUTF8CString(string, stringUTF8, numChars);
         printf("%s\n", stringUTF8);
+        JSStringRelease(string);
     }
     
     return JSValueMakeUndefined(context);
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index c550636..a2de4b77 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,14 @@
+2019-05-16  David Kilzer  <ddkilzer@apple.com>
+
+        REGRESSION (r15133): Fix leak of JSStringRef in minidom
+        <https://webkit.org/b/197968>
+        <rdar://problem/50872430>
+
+        Reviewed by Joseph Pecoraro.
+
+        * API/tests/minidom.c:
+        (print): Call JSStringRelease() to fix the leak.
+
 2019-05-16  Ross Kirsling  <ross.kirsling@sony.com>
 
         [JSC] Invalid AssignmentTargetType should be an early error.
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index f5ad466..0590e8a 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,5 +1,17 @@
 2019-05-16  David Kilzer  <ddkilzer@apple.com>
 
+        REGRESSION (r15133): Fix leak of JSStringRef in minidom
+        <https://webkit.org/b/197968>
+        <rdar://problem/50872430>
+
+        Reviewed by Joseph Pecoraro.
+
+        * TestWebKitAPI/Tests/WebKitObjC/UserContentTest.mm:
+        (expectScriptValueIsString): Drive-by fix to use adopt() instead
+        of JSRetainPtr<JSStringRef> string(Adopt, JSValueToStringCopy(...)).
+
+2019-05-16  David Kilzer  <ddkilzer@apple.com>
+
         REGRESSION (r84160): Leak of OpaqueJSString under WTR::JSTestRunner::pathToLocalResource (32 bytes) in com.apple.WebKit.WebContent running layout tests
         <https://webkit.org/b/197965>
 
diff --git a/Tools/TestWebKitAPI/Tests/WebKitObjC/UserContentTest.mm b/Tools/TestWebKitAPI/Tests/WebKitObjC/UserContentTest.mm
index b63d1d6..4fba91fd 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitObjC/UserContentTest.mm
+++ b/Tools/TestWebKitAPI/Tests/WebKitObjC/UserContentTest.mm
@@ -77,7 +77,7 @@
     JSValueRef scriptValue = WKSerializedScriptValueDeserialize(serializedScriptValue, scriptContext, 0);
     EXPECT_TRUE(JSValueIsString(scriptContext, scriptValue));
     
-    JSRetainPtr<JSStringRef> scriptString(Adopt, JSValueToStringCopy(scriptContext, scriptValue, 0));
+    auto scriptString = adopt(JSValueToStringCopy(scriptContext, scriptValue, 0));
     EXPECT_TRUE(JSStringIsEqualToUTF8CString(scriptString.get(), expectedValue));
     
     JSGlobalContextRelease(scriptContext);