From d4468833b85b8c8f340bc9c3bb6572a245fd5982 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Sun, 15 Aug 2021 13:40:36 +0100 Subject: Restrict total font faces to 16 bit range The substitution tables expect there to be no more than 65535 font faces available. Enforce this at load, so there aren't any unwanted surprises later. --- src/rufl_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/rufl_init.c') diff --git a/src/rufl_init.c b/src/rufl_init.c index 2fa81c3..4005203 100644 --- a/src/rufl_init.c +++ b/src/rufl_init.c @@ -267,7 +267,9 @@ rufl_code rufl_init_font_list(void) font_list_context context = 0; char identifier[80], local_name[80]; - while (context != -1) { + /* Permit up to 65535 font faces (we rely on 16bits of storage + * being sufficient in the substitution tables. */ + while (context != -1 && rufl_font_list_entries < UINT16_MAX) { /* read identifier */ rufl_fm_error = xfont_list_fonts((byte *)identifier, font_RETURN_FONT_NAME | -- cgit v1.2.3