]> granicus.if.org Git - re2c/commit
Fixed bug #142 "segvault with null terminated input"
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 11 May 2016 14:17:17 +0000 (15:17 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 11 May 2016 14:26:56 +0000 (15:26 +0100)
commit54711f61242c4ff4a744ab33d4cb5a3530ddcf02
treee0b33d41a1bfd381ada0d39de5c77ece99fc5b8f
parent68cfccd6a1a3366968887a6205819bb441c0573d
Fixed bug #142 "segvault with null terminated input"

Steps to reproduce:
    $ echo -ne "&\x00" > A
    $ re2c A
    Segmentation fault

Analyses: when re2c finds NULL in the input file, it checks for the
end of input; if indeed it has reached the end of input, it stops.
Otherwise, it's just some NULL byte in the middle of input; it should
be handled like any other character.

The first case (NULL as end of input) was handled correctly, but
in the second case (NULL in the middle of input) re2c crashed:
someone forgot to put an appropriate 'goto' statement, which caused
completely ad-hoc control flow in lexer.
re2c/bootstrap/src/parse/lex.cc
re2c/src/parse/lex.re
re2c/test/bug142.c [new file with mode: 0644]
re2c/test/bug142.re [new file with mode: 0644]