[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/generic

Caolán McNamara caolanm at redhat.com
Tue May 21 08:17:15 PDT 2013


 vcl/generic/fontmanager/fontconfig.cxx |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

New commits:
commit f3db0733b5007ca64a6d755f603970edc5dfd5c4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 20 20:37:27 2013 +0100

    absoletely guarantee there is no mem leak
    
    Change-Id: If6960dea479bb8970cb94aa05a3c9d44bf60cfc5
    (cherry picked from commit 1704b1200d39eba8e235ca5c13c5a931d07a98b3)

diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx
index 3e23fc9..1b36980 100644
--- a/vcl/generic/fontmanager/fontconfig.cxx
+++ b/vcl/generic/fontmanager/fontconfig.cxx
@@ -806,20 +806,18 @@ namespace
     OString mapToFontConfigLangTag(const LanguageTag &rLangTag)
     {
 #if defined(FC_VERSION) && (FC_VERSION >= 20492)
-        FcStrSet *pLangSet = FcGetLangs();
+        boost::shared_ptr<FcStrSet> xLangSet(FcGetLangs(), FcStrSetDestroy);
         OString sLangAttrib;
 
         sLangAttrib = OUStringToOString(rLangTag.getBcp47(), RTL_TEXTENCODING_UTF8).toAsciiLowerCase();
-        if (FcStrSetMember(pLangSet, (const FcChar8*)sLangAttrib.getStr()))
+        if (FcStrSetMember(xLangSet.get(), (const FcChar8*)sLangAttrib.getStr()))
         {
-            FcStrSetDestroy(pLangSet);
             return sLangAttrib;
         }
 
         sLangAttrib = OUStringToOString(rLangTag.getLanguageAndScript(), RTL_TEXTENCODING_UTF8).toAsciiLowerCase();
-        if (FcStrSetMember(pLangSet, (const FcChar8*)sLangAttrib.getStr()))
+        if (FcStrSetMember(xLangSet.get(), (const FcChar8*)sLangAttrib.getStr()))
         {
-            FcStrSetDestroy(pLangSet);
             return sLangAttrib;
         }
 
@@ -829,16 +827,14 @@ namespace
         if (!sRegion.isEmpty())
         {
             sLangAttrib = sLang + OString('-') + sRegion;
-            if (FcStrSetMember(pLangSet, (const FcChar8*)sLangAttrib.getStr()))
+            if (FcStrSetMember(xLangSet.get(), (const FcChar8*)sLangAttrib.getStr()))
             {
-                FcStrSetDestroy(pLangSet);
                 return sLangAttrib;
             }
         }
 
-        if (FcStrSetMember(pLangSet, (const FcChar8*)sLang.getStr()))
+        if (FcStrSetMember(xLangSet.get(), (const FcChar8*)sLang.getStr()))
         {
-            FcStrSetDestroy(pLangSet);
             return sLang;
         }
 


More information about the Libreoffice-commits mailing list