summaryrefslogtreecommitdiffstats
path: root/sal/cppunittester
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-04-24 00:09:19 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-04-24 00:13:28 +0900
commit1ec836760853e9e220d471cf39f2533f0828f00e (patch)
treeaa481fb529d129a16af492818f63858a1af757d8 /sal/cppunittester
parentfix sd layout unit test (diff)
downloadcore-1ec836760853e9e220d471cf39f2533f0828f00e.tar.gz
core-1ec836760853e9e220d471cf39f2533f0828f00e.zip
Avoid possible memory leaks in case of exceptions
Change-Id: I047fd88a89900153089a55b6af123f11fb8bde55
Diffstat (limited to 'sal/cppunittester')
-rw-r--r--sal/cppunittester/cppunittester.cxx10
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