Mercurial > octave
changeset 23118:46b914a213db stable
Workaround segfault when an error occurs while printing (bug #49779)
* print.m: check early that the requested directory exists and the requested
file is writable
* __print_parse_opts__.m: error out if the specified device/extension is unknown
author | Avinoam Kalma <a.kalma@gmail.com> |
---|---|
date | Mon, 30 Jan 2017 21:42:38 +0100 |
parents | 8cb4a2c07bce |
children | b20bd0cd2f13 a7523328f1f7 |
files | scripts/plot/util/print.m scripts/plot/util/private/__print_parse_opts__.m |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/print.m Wed Jan 25 16:08:52 2017 -0800 +++ b/scripts/plot/util/print.m Mon Jan 30 21:42:38 2017 +0100 @@ -314,6 +314,18 @@ opts = __print_parse_opts__ (varargin{:}); + folder = fileparts (opts.name); + if (! isempty (folder) && ! exist (folder,"dir")) + error ("print: directory %s does not exist", folder); + endif + + fid = fopen (opts.name, "w+"); + if (fid == -1) + error ("print: cannot open file %s for writing", opts.name); + endif + fclose (fid); + unlink (opts.name); + opts.pstoedit_cmd = @pstoedit; opts.fig2dev_cmd = @fig2dev; opts.latex_standalone = @latex_standalone;
--- a/scripts/plot/util/private/__print_parse_opts__.m Wed Jan 25 16:08:52 2017 -0800 +++ b/scripts/plot/util/private/__print_parse_opts__.m Mon Jan 30 21:42:38 2017 +0100 @@ -262,7 +262,7 @@ if (any (match)) default_suffix = suffixes{match}; else - default_suffix = arg_st.devopt; + error ("print: unknown device %s", arg_st.devopt); endif if (dot == 0 && ! isempty (arg_st.name))