forked from len0rd/rockbox
Don't accept 0 for the width or height of a progress bar in the %pb tag. A zero width causes a divide by zero, and a zero height simply doesn't make any sense, so we assume it was a mistake.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18863 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4e14f2d6dd
commit
a42602b350
1 changed files with 19 additions and 0 deletions
|
|
@ -870,26 +870,45 @@ static int parse_progressbar(const char *wps_bufptr,
|
||||||
if (!(ptr = parse_list("sdddd", &set, '|', ptr, &filename,
|
if (!(ptr = parse_list("sdddd", &set, '|', ptr, &filename,
|
||||||
&x, &y, &width, &height)))
|
&x, &y, &width, &height)))
|
||||||
return WPS_ERROR_INVALID_PARAM;
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
|
||||||
if (LIST_VALUE_PARSED(set, PB_FILENAME)) /* filename */
|
if (LIST_VALUE_PARSED(set, PB_FILENAME)) /* filename */
|
||||||
bmp_names[PROGRESSBAR_BMP+wps_data->progressbar_count] = filename;
|
bmp_names[PROGRESSBAR_BMP+wps_data->progressbar_count] = filename;
|
||||||
|
|
||||||
if (LIST_VALUE_PARSED(set, PB_X)) /* x */
|
if (LIST_VALUE_PARSED(set, PB_X)) /* x */
|
||||||
pb->x = x;
|
pb->x = x;
|
||||||
else
|
else
|
||||||
pb->x = vp->x;
|
pb->x = vp->x;
|
||||||
|
|
||||||
if (LIST_VALUE_PARSED(set, PB_WIDTH)) /* width */
|
if (LIST_VALUE_PARSED(set, PB_WIDTH)) /* width */
|
||||||
|
{
|
||||||
|
/* A zero width causes a divide-by-zero error later, so reject it */
|
||||||
|
if (width == 0)
|
||||||
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
|
||||||
pb->width = width;
|
pb->width = width;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
pb->width = vp->width - pb->x;
|
pb->width = vp->width - pb->x;
|
||||||
|
|
||||||
if (LIST_VALUE_PARSED(set, PB_HEIGHT)) /* height, default to font height */
|
if (LIST_VALUE_PARSED(set, PB_HEIGHT)) /* height, default to font height */
|
||||||
|
{
|
||||||
|
/* A zero height makes no sense - reject it */
|
||||||
|
if (height == 0)
|
||||||
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
|
||||||
pb->height = height;
|
pb->height = height;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
pb->height = font_height;
|
pb->height = font_height;
|
||||||
|
|
||||||
if (LIST_VALUE_PARSED(set, PB_Y)) /* y */
|
if (LIST_VALUE_PARSED(set, PB_Y)) /* y */
|
||||||
pb->y = y;
|
pb->y = y;
|
||||||
else
|
else
|
||||||
pb->y = line_y_pos + (font_height-pb->height)/2;
|
pb->y = line_y_pos + (font_height-pb->height)/2;
|
||||||
|
|
||||||
wps_data->viewports[wps_data->num_viewports].pb = pb;
|
wps_data->viewports[wps_data->num_viewports].pb = pb;
|
||||||
wps_data->progressbar_count++;
|
wps_data->progressbar_count++;
|
||||||
|
|
||||||
/* Skip the rest of the line */
|
/* Skip the rest of the line */
|
||||||
return skip_end_of_line(wps_bufptr)-1;
|
return skip_end_of_line(wps_bufptr)-1;
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue