diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2011-02-14 12:56:52 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2011-02-14 12:56:52 +0000 |
commit | 3d69933e45f711da98f64e4c1753c6a04cd14fa4 (patch) | |
tree | 9d173ec7ddc98fcfada3083fc9f011e95f975c2e | |
parent | 9336ea3ac8566712edbc70692ec127e021a7bb73 (diff) | |
download | netsurf-3d69933e45f711da98f64e4c1753c6a04cd14fa4.tar.gz netsurf-3d69933e45f711da98f64e4c1753c6a04cd14fa4.tar.bz2 |
Avoid potential divide by 0.
svn path=/trunk/netsurf/; revision=11675
-rw-r--r-- | render/layout.c | 23 |
1 files changed, 15 insertions, 8 deletions
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 || |