Mercurial > octave
changeset 26640:c18e59476795 stable
file id must not be single for textscan and other file I/O funcs (bug #55577)
* oct-stream.cc (stream_list::get_info): Error if file id is single precision.
(stream_list::get_file_number): Likewise.
* file-io.cc: Ensure textscan input validation error is tested.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sun, 27 Jan 2019 10:53:25 -0800 |
parents | e2e1aed33f7c |
children | b6e65db78f0c |
files | libinterp/corefcn/file-io.cc libinterp/corefcn/oct-stream.cc |
diffstat | 2 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Sun Jan 27 19:01:50 2019 +0100 +++ b/libinterp/corefcn/file-io.cc Sun Jan 27 10:53:25 2019 -0800 @@ -2278,8 +2278,8 @@ /* ## Test input validation %!error textscan () -%!error textscan (single (40)) -%!error textscan ({40}) +%!error <file id must be> textscan (single (4)) +%!error <file id must be> textscan ({4}) %!error <must be a string> textscan ("Hello World", 2) %!error <at most one character or> %! textscan ("Hello World", "%s", "EndOfLine", 3);
--- a/libinterp/corefcn/oct-stream.cc Sun Jan 27 19:01:50 2019 +0100 +++ b/libinterp/corefcn/oct-stream.cc Sun Jan 27 10:53:25 2019 -0800 @@ -7503,6 +7503,9 @@ { int conv_err = 0; + if (fid.is_single_type ()) + ::error ("file id must be a file object or integer value"); + int int_fid = convert_to_valid_int (fid, conv_err); if (conv_err) @@ -7584,6 +7587,8 @@ } } } + else if (fid.is_single_type ()) + ::error ("file id must be a file object, std::string, or integer value"); else { int conv_err = 0;