]> git.tue.mpg.de Git - lopsub.git/commitdiff
Don't print invalid line numbers in error messages.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 31 Oct 2023 19:52:06 +0000 (20:52 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 7 Nov 2023 14:04:13 +0000 (15:04 +0100)
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

index f603b8ee4636a7e48af43246144e89e451e6e109..58aab83fa4def89a84eefe6bf74f00e3a6f9b7dc 100644 (file)
@@ -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);