diff -Naur grub-new5/grub-core/gfxmenu/gui_list.c grub-new6/grub-core/gfxmenu/gui_list.c --- grub-new5/grub-core/gfxmenu/gui_list.c 2013-07-17 18:57:56.597740755 +0400 +++ grub-new6/grub-core/gfxmenu/gui_list.c 2013-07-17 20:07:37.664064169 +0400 @@ -148,6 +148,33 @@ self->theme_dir); self->need_to_recreate_scrollbar = 0; + + /* Sanity checks. */ + if (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0) + { + grub_gfxmenu_box_t box = self->menu_box; + grub_gfxmenu_box_t frame = self->scrollbar_frame; + grub_gfxmenu_box_t thumb = self->scrollbar_thumb; + int box_vertical_pad = (box->get_top_pad (box) + + box->get_bottom_pad (box)); + int frame_horizontal_pad = (frame->get_left_pad (frame) + + frame->get_right_pad (frame)); + int frame_vertical_pad = (frame->get_top_pad (frame) + + frame->get_bottom_pad (frame)); + int thumb_horizontal_pad = (thumb->get_left_pad (thumb) + + thumb->get_right_pad (thumb)); + int thumb_vertical_pad = (thumb->get_top_pad (thumb) + + thumb->get_bottom_pad (thumb)); + int scrollbar_height = self->bounds.height - box_vertical_pad; + + if (self->scrollbar_width < frame_horizontal_pad + + thumb_horizontal_pad + || scrollbar_height < frame_vertical_pad + thumb_vertical_pad) + { + self->draw_scrollbar = 0; + return 0; + } + } } return (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0); @@ -228,8 +255,18 @@ frame->set_content_size (frame, scrollbar_width - frame_horizontal_pad, tracklen); - int thumby = tracktop + tracklen * (value - min) / (max - min); + int thumby; int thumbheight = tracklen * extent / (max - min) + 1; + if (thumbheight >= thumb_vertical_pad) + { + thumby = tracktop + tracklen * (value - min) / (max - min); + } + else /* Rare occasion. Thumb height is too low. */ + { + thumbheight = thumb_vertical_pad; + thumby = tracktop + ((tracklen - thumb_vertical_pad) * (value - min) + / (max - extent)); + } thumb->set_content_size (thumb, scrollbar_width - frame_horizontal_pad - thumb_horizontal_pad, @@ -584,7 +621,7 @@ } else if (grub_strcmp (name, "scrollbar_width") == 0) { - self->scrollbar_width = grub_strtol (value, 0, 10); + self->scrollbar_width = grub_strtoul (value, 0, 10); } else if (grub_strcmp (name, "scrollbar") == 0) {