Mercurial > octave
changeset 26531:481ac37b0e0e stable
lo-sysdep.cc: Fix static analyzer detected issue (bug #55464).
* lo-sysdep.cc (putenv_wrapper): Fix use after free.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 13 Jan 2019 14:31:16 +0100 |
parents | dc02f20df07d |
children | 4dae224112a1 |
files | liboctave/system/lo-sysdep.cc |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/system/lo-sysdep.cc Sun Jan 13 11:40:38 2019 +0100 +++ b/liboctave/system/lo-sysdep.cc Sun Jan 13 14:31:16 2019 +0100 @@ -40,6 +40,7 @@ # include <wchar.h> # include "lo-hash.h" +# include "unwind-prot.h" #endif namespace octave @@ -178,7 +179,8 @@ #if defined (OCTAVE_USE_WINDOWS_API) wchar_t *wnew_item = u8_to_wchar (new_item); - std::free (static_cast<void *> (new_item)); + octave::unwind_protect frame; + frame.add_fcn (std::free, static_cast<void *> (new_item)); if (_wputenv (wnew_item) < 0) (*current_liboctave_error_handler) ("putenv (%s) failed", new_item); #else