Reproducible null deref under ScriptedAnimationController::createDisplayRefreshMonitor
[WebKit-https.git] / Source / WebCore / platform / graphics / DisplayRefreshMonitor.cpp
index 0559dc525fdd6f75784f7732c1a9bc016dd6b4ff..fa8c02b6b8ab19b6f07ab1a843aeacdb6c1900bd 100644 (file)
 
 namespace WebCore {
 
 
 namespace WebCore {
 
-PassRefPtr<DisplayRefreshMonitor> DisplayRefreshMonitor::create(DisplayRefreshMonitorClient* client)
+RefPtr<DisplayRefreshMonitor> DisplayRefreshMonitor::create(DisplayRefreshMonitorClient* client)
 {
     PlatformDisplayID displayID = client->displayID();
 
 {
     PlatformDisplayID displayID = client->displayID();
 
-    if (RefPtr<DisplayRefreshMonitor> monitor = client->createDisplayRefreshMonitor(displayID))
-        return monitor.release();
+    if (Optional<RefPtr<DisplayRefreshMonitor>> monitor = client->createDisplayRefreshMonitor(displayID))
+        return monitor.value();
+
+    // If ChromeClient returned Nullopt, we'll go ahead and make one of the default type.
 
 #if PLATFORM(MAC)
     return DisplayRefreshMonitorMac::create(displayID);
 
 #if PLATFORM(MAC)
     return DisplayRefreshMonitorMac::create(displayID);