Crash in -[WKWebView _initializeWithConfiguration:]
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jun 2017 22:09:01 +0000 (22:09 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jun 2017 22:09:01 +0000 (22:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173126
<rdar://problem/32664993>

Reviewed by Darin Adler.

Follow up to previous fix; when setting NSString properties, store a copy of
the string rather than the NSString itself.

* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _overrideContentSecurityPolicy]):
(-[WKWebViewConfiguration _setOverrideContentSecurityPolicy:]):
(-[WKWebViewConfiguration _setMediaContentTypesRequiringHardwareSupport:]):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

index e3fee71..c67444e 100644 (file)
@@ -1,3 +1,20 @@
+2017-06-09  Jer Noble  <jer.noble@apple.com>
+
+        Crash in -[WKWebView _initializeWithConfiguration:]
+        https://bugs.webkit.org/show_bug.cgi?id=173126
+        <rdar://problem/32664993>
+
+        Reviewed by Darin Adler.
+
+        Follow up to previous fix; when setting NSString properties, store a copy of
+        the string rather than the NSString itself.
+
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration copyWithZone:]):
+        (-[WKWebViewConfiguration _overrideContentSecurityPolicy]):
+        (-[WKWebViewConfiguration _setOverrideContentSecurityPolicy:]):
+        (-[WKWebViewConfiguration _setMediaContentTypesRequiringHardwareSupport:]):
+
 2017-06-09  Chris Dumez  <cdumez@apple.com>
 
         Use WTF::Function instead of std::function in StorageManager
index c9314cb..fa83d0f 100644 (file)
@@ -137,7 +137,7 @@ private:
 #endif
     BOOL _needsStorageAccessFromFileURLsQuirk;
 
-    NSString *_overrideContentSecurityPolicy;
+    RetainPtr<NSString> _overrideContentSecurityPolicy;
     RetainPtr<NSString> _mediaContentTypesRequiringHardwareSupport;
 }
 
@@ -331,10 +331,10 @@ private:
     configuration->_applePayEnabled = self->_applePayEnabled;
 #endif
     configuration->_needsStorageAccessFromFileURLsQuirk = self->_needsStorageAccessFromFileURLsQuirk;
-    configuration->_overrideContentSecurityPolicy = self->_overrideContentSecurityPolicy;
+    configuration->_overrideContentSecurityPolicy = adoptNS([self->_overrideContentSecurityPolicy copyWithZone:zone]);
 
     configuration->_urlSchemeHandlers.set(adoptNS([self._urlSchemeHandlers mutableCopyWithZone:zone]));
-    configuration->_mediaContentTypesRequiringHardwareSupport = self._mediaContentTypesRequiringHardwareSupport;
+    configuration->_mediaContentTypesRequiringHardwareSupport = adoptNS([self._mediaContentTypesRequiringHardwareSupport copyWithZone:zone]);
 
     return configuration;
 }
@@ -813,12 +813,12 @@ static NSString *defaultApplicationNameForUserAgent()
 
 - (NSString *)_overrideContentSecurityPolicy
 {
-    return _overrideContentSecurityPolicy;
+    return _overrideContentSecurityPolicy.get();
 }
 
 - (void)_setOverrideContentSecurityPolicy:(NSString *)overrideContentSecurityPolicy
 {
-    _overrideContentSecurityPolicy = overrideContentSecurityPolicy;
+    _overrideContentSecurityPolicy = adoptNS([overrideContentSecurityPolicy copy]);
 }
 
 - (NSString *)_mediaContentTypesRequiringHardwareSupport
@@ -828,7 +828,7 @@ static NSString *defaultApplicationNameForUserAgent()
 
 - (void)_setMediaContentTypesRequiringHardwareSupport:(NSString *)mediaContentTypesRequiringHardwareSupport
 {
-    _mediaContentTypesRequiringHardwareSupport = mediaContentTypesRequiringHardwareSupport;
+    _mediaContentTypesRequiringHardwareSupport = adoptNS([mediaContentTypesRequiringHardwareSupport copy]);
 }
 
 @end