summaryrefslogtreecommitdiff
path: root/src/flex.skl
diff options
context:
space:
mode:
authorHarald van Dijk <harald@gigawatt.nl>2017-01-10 22:37:49 +0100
committerWill Estes <westes575@gmail.com>2017-01-11 21:04:28 -0500
commite666829949f82b3d8b7c722f7db5a8af38e93a2c (patch)
tree66c35561f8e7d18f1f44b84a4d8821da7eac35b1 /src/flex.skl
parent7f263e35204db8ade3f0fb424f4597d7758caf25 (diff)
c++: Fix yyrestart(NULL) SEGV.
Binding a reference to a dereferenced null pointer is invalid and compilers optimise away the &file == 0 check. We need a real stream. yyin is available already, and yyrestart(NULL) is only supported when yyin will not be used, so there is no harm in just passing in that. Since we now always have a valid stream, we can skip the null check too. Fixes #98.
Diffstat (limited to 'src/flex.skl')
-rw-r--r--src/flex.skl5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/flex.skl b/src/flex.skl
index 23e7063..66b7c1e 100644
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -1896,6 +1896,9 @@ m4_ifdef( [[M4_YY_USE_LINENO]],
*/
void yyFlexLexer::yyrestart( std::istream* input_file )
{
+ if( ! input_file ) {
+ input_file = &yyin;
+ }
yyrestart( *input_file );
}
%endif
@@ -2057,7 +2060,7 @@ static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG)
b->yy_input_file = file;
%endif
%if-c++-only
- b->yy_input_file = (&file == 0) ? NULL : file.rdbuf();
+ b->yy_input_file = file.rdbuf();
%endif
b->yy_fill_buffer = 1;