Mercurial > octave
changeset 25424:beb43248d602 stable
Avoid segfault with textscan (bug #53786).
* oct-stream.cc (textscan::skip_whitespace): Check for length of cell before
getting element.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 02 Jun 2018 18:28:38 +0200 |
parents | cdaa884568b1 |
children | 2b3c3c8c8360 |
files | libinterp/corefcn/oct-stream.cc |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc Thu May 24 19:20:35 2018 -0700 +++ b/libinterp/corefcn/oct-stream.cc Sat Jun 02 18:28:38 2018 +0200 @@ -3758,8 +3758,9 @@ std::string tmp (comment_len, '\0'); char *look = is.read (&tmp[0], comment_len-1, pos); // already read first char - if (is && ! strncmp (comment_style(0).string_value ().substr (1) - .c_str (), look, comment_len-1)) + if (is && comment_style.numel () > 0 && + ! strncmp (comment_style(0).string_value ().substr (1).c_str (), + look, comment_len-1)) { found_comment = true;