From 87d9e84f285654db3bc25e7c96a542fbed79a216 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 5 Sep 2019 15:45:17 +0200 Subject: [PATCH] Avoid infinite loops when rendering columns --- weasyprint/layout/columns.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/weasyprint/layout/columns.py b/weasyprint/layout/columns.py index cea2e0c04..e04cf4185 100644 --- a/weasyprint/layout/columns.py +++ b/weasyprint/layout/columns.py @@ -183,7 +183,12 @@ def create_column_box(children): # example when the next box can't be separated from its own # next box. In this case we don't try to find the real value # and let the workaround below fix this for us. - if next_box_size - empty_space > 0: + # + # We also want to avoid very small values that may have been + # introduced by rounding errors. As the workaround below at + # least adds 1 pixel for each loop, we can ignore lost spaces + # lower than 1px. + if next_box_size - empty_space > 1: lost_space = min(lost_space, next_box_size - empty_space) # Stop if we already rendered the whole content