[Libreoffice-commits] core.git: bridges/source

Caolán McNamara caolanm at redhat.com
Mon Nov 13 09:16:40 UTC 2017


 bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 70fa61918415f642228127847491224078532218
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Nov 11 19:42:18 2017 +0000

    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 at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

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)


More information about the Libreoffice-commits mailing list