Mercurial > octave
changeset 23741:3bb1c94b41f2
* file-io.cc (Ftmpfile): Close tmp file if stream creation fails.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 06 Jul 2017 16:26:56 -0400 |
parents | 38188d1aaf3f |
children | 1f0daaf81955 |
files | libinterp/corefcn/file-io.cc |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Thu Jul 06 16:25:38 2017 -0400 +++ b/libinterp/corefcn/file-io.cc Thu Jul 06 16:26:56 2017 -0400 @@ -2872,16 +2872,18 @@ octave::stream s = octave_stdiostream::create (nm, fid, md); if (! s) - error ("tmpfile: failed to create octave_stdiostream object"); + { + fclose (fid); + + error ("tmpfile: failed to create octave_stdiostream object"); + } octave::stream_list& streams = interp.get_stream_list (); retval = ovl (streams.insert (s), ""); } else - { - retval = ovl (-1, std::strerror (errno)); - } + retval = ovl (-1, std::strerror (errno)); return retval; }