From 0194e4bb55ca90f447344403ed01fea5a7a3fed6 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 31 Mar 2010 19:14:01 +0000 Subject: avoid diviosion by zero errors; svn path=/trunk/netsurf/; revision=10223 --- framebuffer/gui.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 62ca77131..8d2759d84 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -1174,15 +1174,20 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, void gui_window_update_extent(struct gui_window *gw) { int pct; + int width; + int height; - pct = (fbtk_get_width(gw->browser) * 100) / - content_get_width(gw->bw->current_content); - fbtk_set_scroll(gw->hscroll, pct); - - pct = (fbtk_get_height(gw->browser) * 100) / - content_get_height(gw->bw->current_content); - fbtk_set_scroll(gw->vscroll, pct); + width = content_get_width(gw->bw->current_content); + if (width != 0) { + pct = (fbtk_get_width(gw->browser) * 100) / width; + fbtk_set_scroll(gw->hscroll, pct); + } + height = content_get_height(gw->bw->current_content); + if (height != 0) { + pct = (fbtk_get_height(gw->browser) * 100) / height; + fbtk_set_scroll(gw->vscroll, pct); + } } void gui_window_set_status(struct gui_window *g, const char *text) -- cgit v1.2.3