From 3d69933e45f711da98f64e4c1753c6a04cd14fa4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 14 Feb 2011 12:56:52 +0000 Subject: Avoid potential divide by 0. svn path=/trunk/netsurf/; revision=11675 --- render/layout.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'render/layout.c') diff --git a/render/layout.c b/render/layout.c index 213082ee6..561a95af5 100644 --- a/render/layout.c +++ b/render/layout.c @@ -1197,14 +1197,21 @@ void layout_float_find_dimensions(int available_width, if (width == AUTO && height == AUTO) { width = content_get_width(box->object); height = content_get_height(box->object); - } else if (width == AUTO) - width = content_get_width(box->object) * - (float) height / - content_get_height(box->object); - else if (height == AUTO) - height = content_get_height(box->object) * - (float) width / - content_get_width(box->object); + } else if (width == AUTO) { + if (content_get_height(box->object)) + width = content_get_width(box->object) * + (float) height / + content_get_height(box->object); + else + width = content_get_width(box->object); + } else if (height == AUTO) { + if (content_get_width(box->object)) + height = content_get_height(box->object) * + (float) width / + content_get_width(box->object); + else + height = content_get_height(box->object); + } } else if (box->gadget && (box->gadget->type == GADGET_TEXTBOX || box->gadget->type == GADGET_PASSWORD || box->gadget->type == GADGET_FILE || -- cgit v1.2.3