diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-04-24 00:09:19 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-04-24 00:13:28 +0900 |
commit | 1ec836760853e9e220d471cf39f2533f0828f00e (patch) | |
tree | aa481fb529d129a16af492818f63858a1af757d8 /sal/cppunittester | |
parent | 2ea006fb605b886f9c9426783e4edf0de46c9af8 (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: I047fd88a89900153089a55b6af123f11fb8bde55
Diffstat (limited to 'sal/cppunittester')
-rw-r--r-- | sal/cppunittester/cppunittester.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index f4c2fc6c299a..f8b9d6459502 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -47,6 +47,7 @@ #include "boost/noncopyable.hpp" #include "boost/ptr_container/ptr_vector.hpp" +#include <boost/scoped_array.hpp> #include "boost/static_assert.hpp" namespace { @@ -108,9 +109,9 @@ class EyecatcherListener public: void startTest( CppUnit::Test* test) SAL_OVERRIDE { - char* tn = new char [ test->getName().length() + 2 ]; - strcpy(tn, test->getName().c_str()); - int len = strlen(tn); + boost::scoped_array<char> tn(new char [ test->getName().length() + 2 ]); + strcpy(tn.get(), test->getName().c_str()); + int len = strlen(tn.get()); for(int i = 0; i < len; i++) { if(!isalnum(tn[i])) @@ -120,8 +121,7 @@ public: } tn[len] = '_'; tn[len + 1] = 0; - setenv("LO_TESTNAME", tn, true); - delete[] tn; + setenv("LO_TESTNAME", tn.get(), true); } void endTest( CppUnit::Test* /* test */ ) SAL_OVERRIDE |