Mercurial > octave
comparison liboctave/util/oct-shlib.cc @ 28175:b895daca20e2 stable
Avoid potential lifetime issues with temporary std::wstring objects.
* sysdep.cc (F__open_with_system_app__, get_regkey_value, get_regkey_names),
file-ops.cc (rename), lo-sysdep.cc (get_dirlist, fopen, getenv_wrapper),
oct-shlib.cc (octave_w32_shlib): Explicitly create std::wstring object with
well-defined lifetime when passing the pointer to the underlying c_str to a
function.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 27 Mar 2020 08:52:33 +0100 |
parents | b3701ea5a48d |
children | 0a5b15007766 |
comparison
equal
deleted
inserted
replaced
28172:65ddd575a5f5 | 28175:b895daca20e2 |
---|---|
299 m_search_all_loaded = true; | 299 m_search_all_loaded = true; |
300 return; | 300 return; |
301 } | 301 } |
302 | 302 |
303 std::string dir = sys::file_ops::dirname (f); | 303 std::string dir = sys::file_ops::dirname (f); |
304 std::wstring wdir = sys::u8_to_wstring (dir); | |
304 SetDllDirectoryW (dir.empty () | 305 SetDllDirectoryW (dir.empty () |
305 ? nullptr : sys::u8_to_wstring (dir).c_str ()); | 306 ? nullptr : wdir.c_str ()); |
306 | 307 |
307 m_handle = LoadLibraryW (sys::u8_to_wstring (m_file).c_str ()); | 308 std::wstring wfile = sys::u8_to_wstring (m_file); |
309 m_handle = LoadLibraryW (wfile.c_str ()); | |
308 | 310 |
309 SetDllDirectoryW (nullptr); | 311 SetDllDirectoryW (nullptr); |
310 | 312 |
311 if (! m_handle) | 313 if (! m_handle) |
312 { | 314 { |