From 7cc5bb8c56295d91f2bd45c10d483dedebe79c97 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 31 Oct 2023 20:52:06 +0100 Subject: [PATCH] Don't print invalid line numbers in error messages. If yylex() fails, yyget_lineno() should not be called because it accesses uninitialized memory: ==23686== Use of uninitialised value of size 4 ==23686== at 0x46FA85D: _itoa_word (_itoa.c:178) ==23686== by 0x4704E14: __printf_buffer (vfprintf-process-arg.c:155) ==23686== by 0x471B91C: __vsprintf_internal (iovsprintf.c:62) ==23686== by 0x47010DD: sprintf (sprintf.c:30) ==23686== by 0x45A019F: lls_convert_config (config_file.l:272) ==23686== by 0x804F0BA: parse_options (misma.c:741) ==23686== by 0x804A879: main (misma.c:1529) Just omit printing the line number for now. --- config_file.l | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config_file.l b/config_file.l index f603b8e..58aab83 100644 --- a/config_file.l +++ b/config_file.l @@ -268,8 +268,7 @@ int lls_convert_config(const char *buf, size_t nbytes, const char *subcmd, if (errctx) { *errctx = malloc(100); if (*errctx) - sprintf(*errctx, "error at line %d", - yyget_lineno(yyscanner)); + sprintf(*errctx, "yylex error"); } } yy_delete_buffer(yybs, yyscanner); -- 2.39.5