Remove potential division by 0 in gfxmenu.

This commit is contained in:
Vladimir Serbinenko 2015-01-21 15:56:53 +01:00
parent 44b38e4988
commit 6866f2ba37
4 changed files with 61 additions and 46 deletions

View file

@ -118,9 +118,15 @@ draw_filled_rect_bar (grub_gui_progress_bar_t self)
f.width + 2, f.height + 2);
/* Bar background. */
int barwidth = (f.width
* (self->value - self->start)
/ (self->end - self->start));
unsigned barwidth;
if (self->end <= self->start
|| self->value <= self->start)
barwidth = 0;
else
barwidth = (f.width
* (self->value - self->start)
/ (self->end - self->start));
grub_video_fill_rect (grub_video_map_rgba_color (self->bg_color),
f.x + barwidth, f.y,
f.width - barwidth, f.height);