From 3173df8b46fb462fd490bdb387489a5dfa9bc314 Mon Sep 17 00:00:00 2001 From: "simon.fraser@apple.com" Date: Mon, 11 Apr 2011 19:07:22 +0000 Subject: [PATCH] 2011-04-11 Simon Fraser Reviewed by Dan Bernstein. Divide by zero in calcColumnWidth https://bugs.webkit.org/show_bug.cgi?id=58230 Test: fast/multicol/huge-column-count.html Make sure we have at least one column, to avoid divide by zero. * rendering/RenderBlock.cpp: (WebCore::RenderBlock::calcColumnWidth): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83470 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 12 ++++++++++++ LayoutTests/fast/multicol/huge-column-count.html | 6 ++++++ .../mac/fast/multicol/huge-column-count-expected.txt | 4 ++++ Source/WebCore/ChangeLog | 14 ++++++++++++++ Source/WebCore/rendering/RenderBlock.cpp | 2 +- 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 LayoutTests/fast/multicol/huge-column-count.html create mode 100644 LayoutTests/platform/mac/fast/multicol/huge-column-count-expected.txt diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index ba1c1b5..2d2a3a3 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,15 @@ +2011-04-11 Simon Fraser + + Reviewed by Dan Bernstein. + + Divide by zero in calcColumnWidth + https://bugs.webkit.org/show_bug.cgi?id=58230 + + Testcase for the bug. + + * fast/multicol/huge-column-count.html: Added. + * platform/mac/fast/multicol/huge-column-count-expected.txt: Added. + 2011-04-11 Csaba Osztrogonác [Qt][WK2]http/tests/loading/preload-append-scan.php fails diff --git a/LayoutTests/fast/multicol/huge-column-count.html b/LayoutTests/fast/multicol/huge-column-count.html new file mode 100644 index 0000000..8d7c2f7 --- /dev/null +++ b/LayoutTests/fast/multicol/huge-column-count.html @@ -0,0 +1,6 @@ + + +This test should not crash. + \ No newline at end of file diff --git a/LayoutTests/platform/mac/fast/multicol/huge-column-count-expected.txt b/LayoutTests/platform/mac/fast/multicol/huge-column-count-expected.txt new file mode 100644 index 0000000..ed1f990 --- /dev/null +++ b/LayoutTests/platform/mac/fast/multicol/huge-column-count-expected.txt @@ -0,0 +1,4 @@ +layer at (0,0) size 800x600 + RenderView at (0,0) size 800x600 +layer at (0,0) size 800x600 + RenderBlock {HTML} at (0,0) size 800x600 diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index b8afea4..a4c87f2 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,17 @@ +2011-04-11 Simon Fraser + + Reviewed by Dan Bernstein. + + Divide by zero in calcColumnWidth + https://bugs.webkit.org/show_bug.cgi?id=58230 + + Test: fast/multicol/huge-column-count.html + + Make sure we have at least one column, to avoid divide by zero. + + * rendering/RenderBlock.cpp: + (WebCore::RenderBlock::calcColumnWidth): + 2011-04-09 Gavin Barraclough Reviewed by Sam Weinig. diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp index b756b1f..8fec803 100644 --- a/Source/WebCore/rendering/RenderBlock.cpp +++ b/Source/WebCore/rendering/RenderBlock.cpp @@ -4212,7 +4212,7 @@ void RenderBlock::calcColumnWidth() desiredColumnCount = max(1, (float)(availWidth + colGap) / (colWidth + colGap)); desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colGap; } else { - desiredColumnCount = min(colCount, (float)(availWidth + colGap) / (colWidth + colGap)); + desiredColumnCount = max(min(colCount, (float)(availWidth + colGap) / (colWidth + colGap)), 1); desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colGap; } setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth); -- 1.8.3.1