aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src/fclang.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-12-10 08:55:36 +0100
committermarha <marha@users.sourceforge.net>2012-12-10 08:55:36 +0100
commita0124a5e8e70979d2c24ef55285da989fdad766a (patch)
tree5cea5c9804a8edf67bc7260e0851a20d21324547 /fontconfig/src/fclang.c
parent514b4afb64ccbf8e954270105ed5064272a2be68 (diff)
parent0328076efb5ff6e62152c09e38d0d11f7931d07b (diff)
downloadvcxsrv-a0124a5e8e70979d2c24ef55285da989fdad766a.tar.gz
vcxsrv-a0124a5e8e70979d2c24ef55285da989fdad766a.tar.bz2
vcxsrv-a0124a5e8e70979d2c24ef55285da989fdad766a.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig libX11 mesa pixman git update 10 dec 2012 Conflicts: fontconfig/src/fcxml.c
Diffstat (limited to 'fontconfig/src/fclang.c')
-rw-r--r--fontconfig/src/fclang.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/fontconfig/src/fclang.c b/fontconfig/src/fclang.c
index b7e70fcfb..65d22a932 100644
--- a/fontconfig/src/fclang.c
+++ b/fontconfig/src/fclang.c
@@ -182,7 +182,7 @@ FcLangNormalize (const FcChar8 *lang)
{
FcChar8 *result = NULL, *s, *orig;
char *territory, *encoding, *modifier;
- size_t llen, tlen = 0, mlen = 0;
+ size_t llen, tlen = 0, mlen = 0, ssize;
if (!lang || !*lang)
return NULL;
@@ -197,6 +197,10 @@ FcLangNormalize (const FcChar8 *lang)
s = FcStrCopy (lang);
if (!s)
goto bail;
+ /* store the original length of 's' here to let FcMemFree know
+ * the correct size since we breaks 's' from now on.
+ */
+ ssize = strlen ((const char *)s) + 1;
/* from the comments in glibc:
*
@@ -282,6 +286,11 @@ FcLangNormalize (const FcChar8 *lang)
else
{
result = s;
+ /* we'll miss the opportunity to reduce the correct size
+ * of the allocated memory for the string after that.
+ */
+ FcMemFree (FC_MEM_STRING, ssize);
+ FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1);
s = NULL;
goto bail1;
}
@@ -295,6 +304,11 @@ FcLangNormalize (const FcChar8 *lang)
else
{
result = s;
+ /* we'll miss the opportunity to reduce the correct size
+ * of the allocated memory for the string after that.
+ */
+ FcMemFree (FC_MEM_STRING, ssize);
+ FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1);
s = NULL;
goto bail1;
}
@@ -312,14 +326,22 @@ FcLangNormalize (const FcChar8 *lang)
else
{
result = s;
+ /* we'll miss the opportunity to reduce the correct size
+ * of the allocated memory for the string after that.
+ */
+ FcMemFree (FC_MEM_STRING, ssize);
+ FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1);
s = NULL;
}
bail1:
if (orig)
- free (orig);
+ FcStrFree (orig);
bail0:
if (s)
+ {
free (s);
+ FcMemFree (FC_MEM_STRING, ssize);
+ }
bail:
if (FcDebug () & FC_DBG_LANGSET)
{