Mercurial > octave
changeset 25714:ad0b4817c09d
Fix lifetime issue with C string references from C++ strings (bug #54398)
* sysdep.cc (same_file_internal): Store C++ wstring for valid C string pointer.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 30 Jul 2018 06:29:43 +0200 |
parents | 5b1e7256a8de |
children | fc410b574693 |
files | libinterp/corefcn/sysdep.cc |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/sysdep.cc Wed Aug 01 12:25:25 2018 -0400 +++ b/libinterp/corefcn/sysdep.cc Mon Jul 30 06:29:43 2018 +0200 @@ -263,8 +263,10 @@ bool retval = false; - const wchar_t *f1 = octave::sys::u8_to_wstring (file1).c_str (); - const wchar_t *f2 = octave::sys::u8_to_wstring (file2).c_str (); + std::wstring file1w = octave::sys::u8_to_wstring (file1); + std::wstring file2w = octave::sys::u8_to_wstring (file2); + const wchar_t *f1 = file1w.c_str (); + const wchar_t *f2 = file2w.c_str (); bool f1_is_dir = GetFileAttributesW (f1) & FILE_ATTRIBUTE_DIRECTORY; bool f2_is_dir = GetFileAttributesW (f2) & FILE_ATTRIBUTE_DIRECTORY;