JSScript needs to retain its cache path NSURL*
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 06:34:44 +0000 (06:34 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 06:34:44 +0000 (06:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194577

Reviewed by Tim Horton.

* API/JSScript.mm:
(+[JSScript scriptFromASCIIFile:inVirtualMachine:withCodeSigning:andBytecodeCache:]):
(-[JSScript dealloc]):

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

Source/JavaScriptCore/API/JSScript.mm
Source/JavaScriptCore/ChangeLog

index fef446d..25fc1c1 100644 (file)
@@ -42,7 +42,7 @@
 @implementation JSScript {
     __weak JSVirtualMachine* m_virtualMachine;
     String m_source;
-    NSURL* m_cachePath;
+    RetainPtr<NSURL> m_cachePath;
     JSC::CachedBytecode m_cachedBytecode;
     JSC::Strong<JSC::JSSourceCode> m_jsSourceCode;
     UniquedStringImpl* m_moduleKey;
@@ -128,7 +128,7 @@ static bool fillBufferWithContentsOfFile(const String& fileName, Vector<LChar>&
     if (!m_cachePath)
         return;
 
-    int fd = open(m_cachePath.path.UTF8String, O_RDONLY);
+    int fd = open([m_cachePath path].UTF8String, O_RDONLY);
     if (fd == -1)
         return;
 
@@ -161,7 +161,7 @@ static bool fillBufferWithContentsOfFile(const String& fileName, Vector<LChar>&
     m_cachedBytecode = JSC::generateModuleBytecode(m_virtualMachine.vm, m_jsSourceCode->sourceCode(), error);
     if (error.isValid())
         return;
-    int fd = open(m_cachePath.path.UTF8String, O_CREAT | O_WRONLY, 0666);
+    int fd = open([m_cachePath path].UTF8String, O_CREAT | O_WRONLY, 0666);
     if (fd == -1)
         return;
     int rc = flock(fd, LOCK_EX | LOCK_NB);
index b1d7069..e96efd2 100644 (file)
@@ -1,3 +1,14 @@
+2019-02-12  Saam barati  <sbarati@apple.com>
+
+        JSScript needs to retain its cache path NSURL*
+        https://bugs.webkit.org/show_bug.cgi?id=194577
+
+        Reviewed by Tim Horton.
+
+        * API/JSScript.mm:
+        (+[JSScript scriptFromASCIIFile:inVirtualMachine:withCodeSigning:andBytecodeCache:]):
+        (-[JSScript dealloc]):
+
 2019-02-12  Robin Morisset  <rmorisset@apple.com>
 
         Make B3Value::returnsBool() more precise