* grub-core/gfxmenu/gui_circular_progress.c (circprog_paint): Avoid
division by-zero and senseless negative divisions. (circprog_set_property): Don't accept negative num_ticks.
This commit is contained in:
parent
bcfa6d72e3
commit
6af7d49b92
2 changed files with 19 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/gfxmenu/gui_circular_progress.c (circprog_paint): Avoid
|
||||||
|
division by-zero and senseless negative divisions.
|
||||||
|
(circprog_set_property): Don't accept negative num_ticks.
|
||||||
|
|
||||||
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/gfxmenu/gui_progress_bar.c (draw_pixmap_bar): Avoid
|
* grub-core/gfxmenu/gui_progress_bar.c (draw_pixmap_bar): Avoid
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct grub_gui_circular_progress
|
||||||
int start;
|
int start;
|
||||||
int end;
|
int end;
|
||||||
int value;
|
int value;
|
||||||
int num_ticks;
|
unsigned num_ticks;
|
||||||
int start_angle;
|
int start_angle;
|
||||||
int ticks_disappear;
|
int ticks_disappear;
|
||||||
char *theme_dir;
|
char *theme_dir;
|
||||||
|
@ -139,15 +139,16 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
|
||||||
center_width, center_height);
|
center_width, center_height);
|
||||||
|
|
||||||
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;
|
||||||
int nticks;
|
unsigned nticks;
|
||||||
int tick_begin;
|
unsigned tick_begin;
|
||||||
int tick_end;
|
unsigned tick_end;
|
||||||
if (self->end == self->start)
|
if (self->end <= self->start
|
||||||
|
|| self->value <= self->start)
|
||||||
nticks = 0;
|
nticks = 0;
|
||||||
else
|
else
|
||||||
nticks = (self->num_ticks
|
nticks = ((unsigned) (self->num_ticks
|
||||||
* (self->value - self->start)
|
* (self->value - self->start)))
|
||||||
/ (self->end - self->start));
|
/ ((unsigned) (self->end - self->start));
|
||||||
/* Do ticks appear or disappear as the value approached the end? */
|
/* Do ticks appear or disappear as the value approached the end? */
|
||||||
if (self->ticks_disappear)
|
if (self->ticks_disappear)
|
||||||
{
|
{
|
||||||
|
@ -160,7 +161,7 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
|
||||||
tick_end = nticks;
|
tick_end = nticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
unsigned i;
|
||||||
for (i = tick_begin; i < tick_end; i++)
|
for (i = tick_begin; i < tick_end; i++)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
@ -168,7 +169,8 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
|
||||||
int angle;
|
int angle;
|
||||||
|
|
||||||
/* Calculate the location of the tick. */
|
/* Calculate the location of the tick. */
|
||||||
angle = self->start_angle + i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
|
angle = self->start_angle
|
||||||
|
+ i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
|
||||||
x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
||||||
y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
||||||
|
|
||||||
|
@ -248,7 +250,7 @@ circprog_set_property (void *vself, const char *name, const char *value)
|
||||||
circular_progress_t self = vself;
|
circular_progress_t self = vself;
|
||||||
if (grub_strcmp (name, "num_ticks") == 0)
|
if (grub_strcmp (name, "num_ticks") == 0)
|
||||||
{
|
{
|
||||||
self->num_ticks = grub_strtol (value, 0, 10);
|
self->num_ticks = grub_strtoul (value, 0, 10);
|
||||||
}
|
}
|
||||||
else if (grub_strcmp (name, "start_angle") == 0)
|
else if (grub_strcmp (name, "start_angle") == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue