summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex White <alex.white@oarcorp.com>2022-03-09 12:39:02 -0600
committerJoel Sherrill <joel@rtems.org>2022-03-09 16:06:09 -0600
commit072f88f4d42e87c992cf420cfb98ae8cce54c177 (patch)
tree8403b323ae079af133987c408f55ce8118014dc2
parentbin2c: Add option for alignment (diff)
downloadrtems-tools-072f88f4d42e87c992cf420cfb98ae8cce54c177.tar.bz2
rtemstoolkit/rld-path.cpp: Fix double free
-rw-r--r--rtemstoolkit/rld-path.cpp20
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;