From 3eddfe51fad0ee20d6d1856755edbc141df9b491 Mon Sep 17 00:00:00 2001 From: Tomasz 'CeDeROM' CEDRO Date: Mon, 17 Mar 2025 05:37:53 +0100 Subject: [PATCH] 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 --- tools/bdf-converter.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/bdf-converter.c b/tools/bdf-converter.c index 86c12287c44..0e54dd3bbfe 100644 --- a/tools/bdf-converter.c +++ b/tools/bdf-converter.c @@ -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; } } }