fcmatch: Set FcResultMatch at the end if the return value is valid.

In the previous code, the result of 'result' in the argument for
FcFontSetSort() and FcFontSetMatch() wasn't predictable and not reliable to
check if the return value is valid or not. this change is to ensure if it's
performed successfully.
This commit is contained in:
Akira TAGOH 2012-03-22 19:15:27 +09:00
parent 1db3e9cdd8
commit 92ac054ce5
1 changed files with 14 additions and 5 deletions

View File

@ -501,11 +501,11 @@ FcFontSetMatchInternal (FcConfig *config,
printf ("\n"); printf ("\n");
FcPatternPrint (best); FcPatternPrint (best);
} }
if (!best) /* assuming that 'result' is initialized with FcResultNoMatch
{ * outside this function */
*result = FcResultNoMatch; if (best)
return 0; *result = FcResultMatch;
}
return best; return best;
} }
@ -522,6 +522,8 @@ FcFontSetMatch (FcConfig *config,
assert (p != NULL); assert (p != NULL);
assert (result != NULL); assert (result != NULL);
*result = FcResultNoMatch;
if (!config) if (!config)
{ {
config = FcConfigGetCurrent (); config = FcConfigGetCurrent ();
@ -547,6 +549,8 @@ FcFontMatch (FcConfig *config,
assert (p != NULL); assert (p != NULL);
assert (result != NULL); assert (result != NULL);
*result = FcResultNoMatch;
if (!config) if (!config)
{ {
config = FcConfigGetCurrent (); config = FcConfigGetCurrent ();
@ -826,6 +830,9 @@ FcFontSetSort (FcConfig *config,
printf ("First font "); printf ("First font ");
FcPatternPrint (ret->fonts[0]); FcPatternPrint (ret->fonts[0]);
} }
if (ret->nfont > 0)
*result = FcResultMatch;
return ret; return ret;
bail2: bail2:
@ -849,6 +856,8 @@ FcFontSort (FcConfig *config,
assert (p != NULL); assert (p != NULL);
assert (result != NULL); assert (result != NULL);
*result = FcResultNoMatch;
if (!config) if (!config)
{ {
config = FcConfigGetCurrent (); config = FcConfigGetCurrent ();