tools/bdf-converter: Fix loop termination condition.
Changing readingbitmap from bool to int, initializing it to the number of bitmaps allocated, decrementing it each time a bitmap is consumed, and using it as the termination condition for the while loop, ensures that loop termination does not depend on data from the file. Note: Patch provided by Nathan Hartman. Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
This commit is contained in:
parent
b1bab5c783
commit
3eddfe51fa
1 changed files with 6 additions and 5 deletions
|
|
@ -391,12 +391,12 @@ static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
|
|||
{
|
||||
char line[BDF_MAX_LINE_LENGTH];
|
||||
uint64_t *bitmap;
|
||||
bool readingbitmap;
|
||||
int readingbitmap;
|
||||
|
||||
bitmap = ginfo->bitmap;
|
||||
readingbitmap = true;
|
||||
readingbitmap = ginfo->bb_h;
|
||||
|
||||
while (readingbitmap)
|
||||
while (readingbitmap > 0)
|
||||
{
|
||||
if (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL)
|
||||
{
|
||||
|
|
@ -404,20 +404,21 @@ static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
|
|||
|
||||
if (strcmp(line, "ENDCHAR") == 0)
|
||||
{
|
||||
readingbitmap = false;
|
||||
readingbitmap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *endptr;
|
||||
*bitmap = strtoul(line, &endptr, 16);
|
||||
bitmap++;
|
||||
readingbitmap--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* error condition */
|
||||
|
||||
readingbitmap = false;
|
||||
readingbitmap = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue