From 0328076efb5ff6e62152c09e38d0d11f7931d07b Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 10 Dec 2012 08:33:13 +0100 Subject: fontconfig libX11 mesa pixman git update 10 dec 2012 libX11 9833489e6c3829a1e835bc0a11f028fc180809e4 mesa 17f5dc57306b8f5079304701e455bf4b927d3cae pixman 8ca4e144724ba2041bc5ef077ccf6d24e7cf4d1f fontconfig 608c5b590bd3428dfcd30f3d68ee8b7131e2f019 --- fontconfig/src/fclang.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'fontconfig/src/fclang.c') 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) { -- cgit v1.2.3