for (; *string; string++) {
int index;
- index = font->bmp[(unsigned short)*string];
+ index = (*string < 0 || *string > 0xFFFF ? 0xFFFF :
+ font->bmp[*string]);
+
if (index == 0xFFFF) {
if (errs)
*errs = 1;
text += l->line_height;
l->page = page;
- l->ypos = text + space + head +
- space * (float)page->first_line->vshortfall[n] /
- page->first_line->space[n];
+ l->ypos = text + space + head;
+ if (page->first_line->space[n]) {
+ l->ypos += space * (float)page->first_line->vshortfall[n] /
+ page->first_line->space[n];
+ }
if (l == page->last_line)
break;
textpos = textwid = 0;
while (*str) {
- glyph = font->bmp[*str];
+ glyph = (*str < 0 || *str > 0xFFFF ? 0xFFFF :
+ font->bmp[*str]);
if (glyph == 0xFFFF) {
str++;