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:
Tomasz 'CeDeROM' CEDRO
2025-03-17 05:37:53 +01:00
committed by Alan C. Assis
parent b1bab5c783
commit 3eddfe51fa
+6 -5
View File
@@ -391,12 +391,12 @@ static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
{ {
char line[BDF_MAX_LINE_LENGTH]; char line[BDF_MAX_LINE_LENGTH];
uint64_t *bitmap; uint64_t *bitmap;
bool readingbitmap; int readingbitmap;
bitmap = ginfo->bitmap; bitmap = ginfo->bitmap;
readingbitmap = true; readingbitmap = ginfo->bb_h;
while (readingbitmap) while (readingbitmap > 0)
{ {
if (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL) 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) if (strcmp(line, "ENDCHAR") == 0)
{ {
readingbitmap = false; readingbitmap = 0;
} }
else else
{ {
char *endptr; char *endptr;
*bitmap = strtoul(line, &endptr, 16); *bitmap = strtoul(line, &endptr, 16);
bitmap++; bitmap++;
readingbitmap--;
} }
} }
else else
{ {
/* error condition */ /* error condition */
readingbitmap = false; readingbitmap = 0;
} }
} }
} }