Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/atf/dist/tools don't use auto_ptr with memory a...



details:   https://anonhg.NetBSD.org/src/rev/f76fad24fffe
branches:  trunk
changeset: 827751:f76fad24fffe
user:      maya <maya%NetBSD.org@localhost>
date:      Sat Nov 11 14:16:06 2017 +0000

description:
don't use auto_ptr with memory allocated by C code
silences alloc-dealloc-mismatch warnings from asan

from joerg

diffstat:

 external/bsd/atf/dist/tools/fs.cpp |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (25 lines):

diff -r ebb362435da4 -r f76fad24fffe external/bsd/atf/dist/tools/fs.cpp
--- a/external/bsd/atf/dist/tools/fs.cpp        Sat Nov 11 13:50:57 2017 +0000
+++ b/external/bsd/atf/dist/tools/fs.cpp        Sat Nov 11 14:16:06 2017 +0000
@@ -707,11 +707,17 @@
 impl::path
 impl::get_current_dir(void)
 {
-    std::auto_ptr< char > cwd;
-    cwd.reset(getcwd(NULL, 0));
-    if (cwd.get() == NULL)
+    char *cwd = getcwd(NULL, 0);
+    if (cwd == NULL)
         throw tools::system_error(IMPL_NAME "::get_current_dir()",
                                 "getcwd() failed", errno);
 
-    return path(cwd.get());
+    try {
+        impl::path p(cwd);
+        free(cwd);
+        return p;
+    } catch(...) {
+        free(cwd);
+        throw;
+    }
 }



Home | Main Index | Thread Index | Old Index