From 625e8f648793d63b3b601660c5f4bc9962b0aca1 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 18 Sep 2022 16:42:26 -0700 Subject: [PATCH] lexer: Make lex_error_expecting_valist() support a longer list. --- src/language/lexer/lexer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index f9236af19f..a2a0da9713 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -519,18 +519,22 @@ void void lex_error_expecting_valist (struct lexer *lexer, va_list args) { - enum { MAX_OPTIONS = 9 }; - const char *options[MAX_OPTIONS]; - int n = 0; - while (n < MAX_OPTIONS) + const char **options = NULL; + size_t allocated = 0; + size_t n = 0; + + for (;;) { const char *option = va_arg (args, const char *); if (!option) break; + if (n >= allocated) + options = x2nrealloc (options, &allocated, sizeof *options); options[n++] = option; } lex_error_expecting_array (lexer, options, n); + free (options); } void -- 2.30.2