From: Andre Noll Date: Tue, 31 Oct 2023 19:52:06 +0000 (+0100) Subject: Don't print invalid line numbers in error messages. X-Git-Url: http://git.tuebingen.mpg.de/?p=lopsub.git;a=commitdiff_plain;h=7cc5bb8c56295d91f2bd45c10d483dedebe79c97 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. --- 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);