diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-11-11 19:42:18 +0000 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-11-13 10:16:05 +0100 |
commit | 70fa61918415f642228127847491224078532218 (patch) | |
tree | 22760e0a1f1809b8ef89c29f285e5ffce00d5c00 /bridges | |
parent | 38c03901406b439ea3453279838894d9c0b4bd3d (diff) |
ofz: Direct-leak
asan reports that the strdups leak and __si_class_type_info takes a
const char* arg
Change-Id: Ie0ee94554689d9246981cb7d6ce0f23917c2d333
Reviewed-on: https://gerrit.libreoffice.org/44641
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'bridges')
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx index ed0d22c618ef..844cd1038449 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx @@ -46,6 +46,7 @@ class RTTI osl::Mutex m_mutex; t_rtti_map m_rttis; + std::vector<OString> m_rttiNames; std::unordered_map<OUString, std::unique_ptr<std::type_info>> m_generatedRttis; @@ -127,14 +128,16 @@ std::type_info * RTTI::getRTTI(typelib_TypeDescription const & pTypeDescr) // ensure availability of base std::type_info * base_rtti = getRTTI( ctd.pBaseTypeDescription->aBase); + m_rttiNames.emplace_back(OString(rttiName)); newRtti.reset( new __cxxabiv1::__si_class_type_info( - strdup( rttiName ), static_cast<__cxxabiv1::__class_type_info *>(base_rtti) )); + m_rttiNames.back().getStr(), static_cast<__cxxabiv1::__class_type_info *>(base_rtti) )); } else { // this class has no base class - newRtti.reset(new __cxxabiv1::__class_type_info( strdup( rttiName ) )); + m_rttiNames.emplace_back(OString(rttiName)); + newRtti.reset(new __cxxabiv1::__class_type_info(m_rttiNames.back().getStr())); } break; } @@ -150,20 +153,23 @@ std::type_info * RTTI::getRTTI(typelib_TypeDescription const & pTypeDescr) } switch (itd.nBaseTypes) { case 0: + m_rttiNames.emplace_back(OString(rttiName)); newRtti.reset( new __cxxabiv1::__class_type_info( - strdup(rttiName))); + m_rttiNames.back().getStr())); break; case 1: + m_rttiNames.emplace_back(OString(rttiName)); newRtti.reset( new __cxxabiv1::__si_class_type_info( - strdup(rttiName), + m_rttiNames.back().getStr(), static_cast< __cxxabiv1::__class_type_info *>( bases[0]))); break; default: { + m_rttiNames.emplace_back(OString(rttiName)); char * pad = new char[ sizeof (__cxxabiv1::__vmi_class_type_info) + ((itd.nBaseTypes - 1) @@ -172,7 +178,7 @@ std::type_info * RTTI::getRTTI(typelib_TypeDescription const & pTypeDescr) __cxxabiv1::__vmi_class_type_info * info = new(pad) __cxxabiv1::__vmi_class_type_info( - strdup(rttiName), + m_rttiNames.back().getStr(), __cxxabiv1::__vmi_class_type_info::__flags_unknown_mask); info->__base_count = itd.nBaseTypes; for (sal_Int32 i = 0; i != itd.nBaseTypes; ++i) |