summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-05-20 20:37:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-05-21 15:50:14 +0100
commitf3db0733b5007ca64a6d755f603970edc5dfd5c4 (patch)
tree4e526efada472490642558b972e2f63263db37ac
parent4b44ca511900772da30b5a938250789d80d24dfe (diff)
absoletely guarantee there is no mem leak
Change-Id: If6960dea479bb8970cb94aa05a3c9d44bf60cfc5 (cherry picked from commit 1704b1200d39eba8e235ca5c13c5a931d07a98b3)
-rw-r--r--vcl/generic/fontmanager/fontconfig.cxx14
1 files changed, 5 insertions, 9 deletions
diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx
index 3e23fc9f21d5..1b36980b9c46 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;
}