Fix segfault when calling clearSelection on a detached RenderObject
authorCarlos Garcia Campos <carlosgc@webkit.org>
Fri, 6 Mar 2015 07:33:11 +0000 (07:33 +0000)
committerAlberto Garcia <berto@igalia.com>
Fri, 6 Mar 2015 07:33:11 +0000 (07:33 +0000)
===================================================================

Gbp-Pq: Name fix-clearselection-segfault.patch

Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderView.cpp

index ed7e012de0a5372a30881e5321e392d04b06f42c..0e0d51e8b7e9881b057b10768eaeca9b11d197f7 100644 (file)
@@ -1828,6 +1828,8 @@ LayoutUnit RenderBox::containingBlockLogicalWidthForContent() const
 #endif
 
     RenderBlock* cb = containingBlock();
+    if (!cb)
+        return LayoutUnit();
     return cb->availableLogicalWidth();
 }
 
@@ -1839,6 +1841,8 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHei
 #endif
 
     RenderBlock* cb = containingBlock();
+    if (!cb)
+        return LayoutUnit();
     return cb->availableLogicalHeight(heightType);
 }
 
index d6095315cac5c735341c8b094c8f82bcb2b77655..c950b16cd155ebef373759afd23cbff7f88085a6 100644 (file)
@@ -1105,7 +1105,7 @@ void RenderView::getSelection(RenderObject*& startRenderer, int& startOffset, Re
 void RenderView::clearSelection()
 {
     layer()->repaintBlockSelectionGaps();
-    setSelection(0, -1, 0, -1, RepaintNewMinusOld);
+    setSelection(nullptr, -1, nullptr, -1, RepaintNewMinusOld);
 }
 
 bool RenderView::printing() const