Title: [255305] branches/safari-610.1.1-branch/Source/WebKit
Revision
255305
Author
[email protected]
Date
2020-01-28 13:50:02 -0800 (Tue, 28 Jan 2020)

Log Message

Cherry-pick r255132. rdar://problem/58871371

    Protect against crashes during WKWebView init function when methods are called before the view is fully initialized
    https://bugs.webkit.org/show_bug.cgi?id=206799
    rdar://problem/58871371

    Reviewed by Sam Weinig.

    Part way through creating WKWebView, some methods can be called and they need to be careful
    not to use anything that may not be initialized yet.

    * UIProcess/API/Cocoa/WKWebView.mm:
    (-[WKWebView dealloc]): Check _page for null, since this might happen if the superclass's
    init method returned nil.

    * UIProcess/API/ios/WKWebViewIOS.mm:
    (-[WKWebView _frameOrBoundsChanged]): Check _page for null, since this might be called
    before object initialization is complete.
    (-[WKWebView setSemanticContentAttribute:]): Ditto.

    * UIProcess/API/mac/WKWebViewMac.mm:
    (-[WKWebView setFrameSize:]): Check _impl for null since this might be called before
    oject initialization is complete.
    (-[WKWebView setUserInterfaceLayoutDirection:]): Ditto.
    (-[WKWebView renewGState]): Ditto.

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

Modified Paths

Diff

Modified: branches/safari-610.1.1-branch/Source/WebKit/ChangeLog (255304 => 255305)


--- branches/safari-610.1.1-branch/Source/WebKit/ChangeLog	2020-01-28 21:50:00 UTC (rev 255304)
+++ branches/safari-610.1.1-branch/Source/WebKit/ChangeLog	2020-01-28 21:50:02 UTC (rev 255305)
@@ -1,5 +1,62 @@
 2020-01-28  Russell Epstein  <[email protected]>
 
+        Cherry-pick r255132. rdar://problem/58871371
+
+    Protect against crashes during WKWebView init function when methods are called before the view is fully initialized
+    https://bugs.webkit.org/show_bug.cgi?id=206799
+    rdar://problem/58871371
+    
+    Reviewed by Sam Weinig.
+    
+    Part way through creating WKWebView, some methods can be called and they need to be careful
+    not to use anything that may not be initialized yet.
+    
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView dealloc]): Check _page for null, since this might happen if the superclass's
+    init method returned nil.
+    
+    * UIProcess/API/ios/WKWebViewIOS.mm:
+    (-[WKWebView _frameOrBoundsChanged]): Check _page for null, since this might be called
+    before object initialization is complete.
+    (-[WKWebView setSemanticContentAttribute:]): Ditto.
+    
+    * UIProcess/API/mac/WKWebViewMac.mm:
+    (-[WKWebView setFrameSize:]): Check _impl for null since this might be called before
+    oject initialization is complete.
+    (-[WKWebView setUserInterfaceLayoutDirection:]): Ditto.
+    (-[WKWebView renewGState]): Ditto.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255132 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-01-26  Darin Adler  <[email protected]>
+
+            Protect against crashes during WKWebView init function when methods are called before the view is fully initialized
+            https://bugs.webkit.org/show_bug.cgi?id=206799
+            rdar://problem/58871371
+
+            Reviewed by Sam Weinig.
+
+            Part way through creating WKWebView, some methods can be called and they need to be careful
+            not to use anything that may not be initialized yet.
+
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView dealloc]): Check _page for null, since this might happen if the superclass's
+            init method returned nil.
+
+            * UIProcess/API/ios/WKWebViewIOS.mm:
+            (-[WKWebView _frameOrBoundsChanged]): Check _page for null, since this might be called
+            before object initialization is complete.
+            (-[WKWebView setSemanticContentAttribute:]): Ditto.
+
+            * UIProcess/API/mac/WKWebViewMac.mm:
+            (-[WKWebView setFrameSize:]): Check _impl for null since this might be called before
+            oject initialization is complete.
+            (-[WKWebView setUserInterfaceLayoutDirection:]): Ditto.
+            (-[WKWebView renewGState]): Ditto.
+
+2020-01-28  Russell Epstein  <[email protected]>
+
         Cherry-pick r255039. rdar://problem/58713379
 
     Background thread with ITP Database should lock when the network process is suspended

Modified: branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (255304 => 255305)


--- branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-01-28 21:50:00 UTC (rev 255304)
+++ branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-01-28 21:50:02 UTC (rev 255305)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -590,11 +590,12 @@
 #if PLATFORM(IOS_FAMILY)
     [_contentView _webViewDestroyed];
 
-    if (_remoteObjectRegistry)
+    if (_page && _remoteObjectRegistry)
         _page->process().processPool().removeMessageReceiver(Messages::RemoteObjectRegistry::messageReceiverName(), _page->identifier());
 #endif
 
-    _page->close();
+    if (_page)
+        _page->close();
 
 #if PLATFORM(IOS_FAMILY)
     [_remoteObjectRegistry _invalidate];
@@ -605,7 +606,8 @@
     CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr);
 #endif
 
-    pageToViewMap().remove(_page.get());
+    if (_page)
+        pageToViewMap().remove(_page.get());
 
     [super dealloc];
 }

Modified: branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (255304 => 255305)


--- branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2020-01-28 21:50:00 UTC (rev 255304)
+++ branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2020-01-28 21:50:02 UTC (rev 255305)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1747,8 +1747,10 @@
             [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(bounds.size)];
 
         BOOL sizeChanged = NO;
-        if (auto drawingArea = _page->drawingArea())
-            sizeChanged = drawingArea->setSize(WebCore::IntSize(bounds.size));
+        if (_page) {
+            if (auto drawingArea = _page->drawingArea())
+                sizeChanged = drawingArea->setSize(WebCore::IntSize(bounds.size));
+        }
 
         if (sizeChanged & [self usesStandardContentView])
             [_contentView setSizeChangedSinceLastVisibleContentRectUpdate:YES];
@@ -2365,7 +2367,8 @@
 {
     [super setSemanticContentAttribute:contentAttribute];
 
-    _page->setUserInterfaceLayoutDirection(toUserInterfaceLayoutDirection(contentAttribute));
+    if (_page)
+        _page->setUserInterfaceLayoutDirection(toUserInterfaceLayoutDirection(contentAttribute));
 }
 
 @end

Modified: branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm (255304 => 255305)


--- branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm	2020-01-28 21:50:00 UTC (rev 255304)
+++ branches/safari-610.1.1-branch/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm	2020-01-28 21:50:02 UTC (rev 255305)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -135,14 +135,15 @@
 {
     [super setFrameSize:size];
     [_safeBrowsingWarning setFrame:self.bounds];
-    _impl->setFrameSize(NSSizeToCGSize(size));
+    if (_impl)
+        _impl->setFrameSize(NSSizeToCGSize(size));
 }
 
 - (void)setUserInterfaceLayoutDirection:(NSUserInterfaceLayoutDirection)userInterfaceLayoutDirection
 {
     [super setUserInterfaceLayoutDirection:userInterfaceLayoutDirection];
-
-    _impl->setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
+    if (_impl)
+        _impl->setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
 }
 
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
@@ -149,7 +150,8 @@
 - (void)renewGState
 ALLOW_DEPRECATED_IMPLEMENTATIONS_END
 {
-    _impl->renewGState();
+    if (_impl)
+        _impl->renewGState();
     [super renewGState];
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to