comparison libinterp/parse-tree/lex.ll @ 23786:10136bfd46a3

lex.ll: Fix heap-buffer-overflow (bug #51533). * lex.ll (lexer::fill_flex_buffer): Check that string is non-empty before looking at last character to see if it is a newline.
author Rik <rik@octave.org>
date Sun, 23 Jul 2017 20:51:24 -0700
parents ea879bc55272
children b481a9baeb61
comparison
equal deleted inserted replaced
23785:99cdc1547054 23786:10136bfd46a3
3660 // 3660 //
3661 // See also comments in push_lexer::append_input. 3661 // See also comments in push_lexer::append_input.
3662 3662
3663 if (buffer_function_text) 3663 if (buffer_function_text)
3664 { 3664 {
3665 function_text += current_input_line; 3665 if (! current_input_line.empty ())
3666 if (current_input_line[current_input_line.length () - 1] != '\n') 3666 {
3667 function_text += "\n"; 3667 function_text += current_input_line;
3668 if (current_input_line.back () != '\n')
3669 function_text += "\n";
3670 }
3668 } 3671 }
3669 } 3672 }
3670 3673
3671 if (! input_buf.empty ()) 3674 if (! input_buf.empty ())
3672 status = input_buf.copy_chunk (buf, max_size); 3675 status = input_buf.copy_chunk (buf, max_size);