[PATCH] Fix memory leak in mapToFontConfigLangTag.

Mark Wielaard (via Code Review) gerrit at gerrit.libreoffice.org
Sun May 19 15:21:30 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3967

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/67/3967/1

Fix memory leak in mapToFontConfigLangTag.

FcGetLangs() will return a new FCStrSet that needs to be freed after usage.

Change-Id: Ie7fe0dd160fa59077d6a90878e70d0e034680812
---
M vcl/generic/fontmanager/fontconfig.cxx
1 file changed, 12 insertions(+), 0 deletions(-)



diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx
index dc8dfa7..3e23fc9 100644
--- a/vcl/generic/fontmanager/fontconfig.cxx
+++ b/vcl/generic/fontmanager/fontconfig.cxx
@@ -811,11 +811,17 @@
 
         sLangAttrib = OUStringToOString(rLangTag.getBcp47(), RTL_TEXTENCODING_UTF8).toAsciiLowerCase();
         if (FcStrSetMember(pLangSet, (const FcChar8*)sLangAttrib.getStr()))
+        {
+            FcStrSetDestroy(pLangSet);
             return sLangAttrib;
+        }
 
         sLangAttrib = OUStringToOString(rLangTag.getLanguageAndScript(), RTL_TEXTENCODING_UTF8).toAsciiLowerCase();
         if (FcStrSetMember(pLangSet, (const FcChar8*)sLangAttrib.getStr()))
+        {
+            FcStrSetDestroy(pLangSet);
             return sLangAttrib;
+        }
 
         OString sLang = OUStringToOString(rLangTag.getLanguage(), RTL_TEXTENCODING_UTF8).toAsciiLowerCase();
         OString sRegion = OUStringToOString(rLangTag.getCountry(), RTL_TEXTENCODING_UTF8).toAsciiLowerCase();
@@ -824,11 +830,17 @@
         {
             sLangAttrib = sLang + OString('-') + sRegion;
             if (FcStrSetMember(pLangSet, (const FcChar8*)sLangAttrib.getStr()))
+            {
+                FcStrSetDestroy(pLangSet);
                 return sLangAttrib;
+            }
         }
 
         if (FcStrSetMember(pLangSet, (const FcChar8*)sLang.getStr()))
+        {
+            FcStrSetDestroy(pLangSet);
             return sLang;
+        }
 
         return OString();
 #else

-- 
To view, visit https://gerrit.libreoffice.org/3967
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie7fe0dd160fa59077d6a90878e70d0e034680812
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Mark Wielaard <mark at klomp.org>



More information about the LibreOffice mailing list