convttf: Add sanity checking to specified defaultchar

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Fri, 29 May 2026 07:34:39 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 8af98332ab3df4b57e41804ce9861751e9cf31db
Author: Solomon Peachy <[email protected]>
Date:   Fri May 29 07:33:36 2026 -0400

    convttf:  Add sanity checking to specified defaultchar
    
    It now matches the logic in convbdf
    
    Change-Id: Ic17fdd4dbed41fad4d3353b9dd314cd24a8ded58

diff --git a/tools/convttf.c b/tools/convttf.c
index b0afe154ff..8a03e238e6 100644
--- a/tools/convttf.c
+++ b/tools/convttf.c
@@ -94,7 +94,7 @@ int pct                     = 0; /* display ttc table if it is not zero. */
 FT_Long         max_char    = 0x10FFFF;
 int             pixel_size  = 15;
 FT_Long         start_char  = 0;
-FT_Long         defaultchar = 0;
+FT_Long         defaultchar = -1;
 FT_Long         limit_char;
 FT_Long         firstchar   = 0;
 FT_Long         lastchar;
@@ -714,7 +714,15 @@ void convttf(char* path, char* destfile, FT_Long face_index)
         if (code <= firstchar)
             firstchar = code;
     }
-    export_font.header.defaultchar = defaultchar - firstchar;
+
+    /* calc default char */
+    if (defaultchar < 0 ||
+        defaultchar < firstchar ||
+        defaultchar > limit_char ||
+        defaultchar > lastchar)
+        defaultchar = firstchar;
+
+    export_font.header.defaultchar = defaultchar;
     export_font.header.firstchar = firstchar;
     export_font.header.size = lastchar - firstchar + 1;
     export_font.header.nbits = idx;
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs