Remove potential division by 0 in gfxmenu.
This commit is contained in:
parent
44b38e4988
commit
6866f2ba37
4 changed files with 61 additions and 46 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Remove potential division by 0 in gfxmenu.
|
||||||
|
|
||||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/normal/menu_text.c (grub_menu_init_page): Avoid
|
* grub-core/normal/menu_text.c (grub_menu_init_page): Avoid
|
||||||
|
|
|
@ -138,6 +138,8 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
|
||||||
(height - center_height) / 2, 0, 0,
|
(height - center_height) / 2, 0, 0,
|
||||||
center_width, center_height);
|
center_width, center_height);
|
||||||
|
|
||||||
|
if (self->num_ticks)
|
||||||
|
{
|
||||||
int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1;
|
int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1;
|
||||||
unsigned nticks;
|
unsigned nticks;
|
||||||
unsigned tick_begin;
|
unsigned tick_begin;
|
||||||
|
@ -182,7 +184,7 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
|
||||||
grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||||
x, y, 0, 0, tick_width, tick_height);
|
x, y, 0, 0, tick_width, tick_height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
grub_gui_restore_viewport (&vpsave);
|
grub_gui_restore_viewport (&vpsave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,9 @@ get_num_shown_items (list_impl_t self)
|
||||||
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
|
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
|
||||||
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
|
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
|
||||||
|
|
||||||
|
if (item_height + item_vspace <= 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
return (self->bounds.height + item_vspace - 2 * boxpad
|
return (self->bounds.height + item_vspace - 2 * boxpad
|
||||||
- max_top_pad - max_bottom_pad
|
- max_top_pad - max_bottom_pad
|
||||||
- box_top_pad - box_bottom_pad) / (item_height + item_vspace);
|
- box_top_pad - box_bottom_pad) / (item_height + item_vspace);
|
||||||
|
|
|
@ -118,7 +118,13 @@ draw_filled_rect_bar (grub_gui_progress_bar_t self)
|
||||||
f.width + 2, f.height + 2);
|
f.width + 2, f.height + 2);
|
||||||
|
|
||||||
/* Bar background. */
|
/* Bar background. */
|
||||||
int barwidth = (f.width
|
unsigned barwidth;
|
||||||
|
|
||||||
|
if (self->end <= self->start
|
||||||
|
|| self->value <= self->start)
|
||||||
|
barwidth = 0;
|
||||||
|
else
|
||||||
|
barwidth = (f.width
|
||||||
* (self->value - self->start)
|
* (self->value - self->start)
|
||||||
/ (self->end - self->start));
|
/ (self->end - self->start));
|
||||||
grub_video_fill_rect (grub_video_map_rgba_color (self->bg_color),
|
grub_video_fill_rect (grub_video_map_rgba_color (self->bg_color),
|
||||||
|
|
Loading…
Reference in a new issue