This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 3eddfe51fa tools/bdf-converter: Fix loop termination condition.
3eddfe51fa is described below

commit 3eddfe51fad0ee20d6d1856755edbc141df9b491
Author: Tomasz 'CeDeROM' CEDRO <to...@cedro.info>
AuthorDate: Mon Mar 17 05:37:53 2025 +0100

    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 <to...@cedro.info>
---
 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 86c12287c4..0e54dd3bbf 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;
         }
     }
 }

Reply via email to