diff options
author | Alex White <alex.white@oarcorp.com> | 2022-03-09 12:39:02 -0600 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2022-03-09 16:06:09 -0600 |
commit | 072f88f4d42e87c992cf420cfb98ae8cce54c177 (patch) | |
tree | 8403b323ae079af133987c408f55ce8118014dc2 /rtemstoolkit | |
parent | bin2c: Add option for alignment (diff) | |
download | rtems-tools-072f88f4d42e87c992cf420cfb98ae8cce54c177.tar.bz2 |
rtemstoolkit/rld-path.cpp: Fix double free
Diffstat (limited to 'rtemstoolkit')
-rw-r--r-- | rtemstoolkit/rld-path.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/rtemstoolkit/rld-path.cpp b/rtemstoolkit/rld-path.cpp index 35af055..61c954d 100644 --- a/rtemstoolkit/rld-path.cpp +++ b/rtemstoolkit/rld-path.cpp @@ -109,23 +109,13 @@ namespace rld } else { - char* buf = 0; - try + std::vector<char> buf (32 * 1024); + if (!::getcwd (buf.data(), buf.size())) { - buf = new char[32 * 1024]; - if (!::getcwd (buf, 32 * 1024)) - { - delete [] buf; - throw rld::error (::strerror (errno), "get current working directory"); - } - path_join (buf, path, apath); - delete [] buf; - } - catch (...) - { - delete [] buf; - throw; + throw rld::error (::strerror (errno), "get current working directory"); } + std::string cwd (buf.data()); + path_join (cwd, path, apath); } strings ps; |