Bug 40452 - Running 'fc-match --all' core dumps when no fonts are installed
This would changes the behavior of FcFontSort(). it won't returns NULL afterward.
This commit is contained in:
parent
cbb6ee1662
commit
a18ca17b62
|
@ -175,6 +175,11 @@ main (int argc, char **argv)
|
||||||
int j;
|
int j;
|
||||||
font_patterns = FcFontSort (0, pat, all ? FcFalse : FcTrue, 0, &result);
|
font_patterns = FcFontSort (0, pat, all ? FcFalse : FcTrue, 0, &result);
|
||||||
|
|
||||||
|
if (!font_patterns || font_patterns->nfont == 0)
|
||||||
|
{
|
||||||
|
fputs("No fonts installed on the system\n", stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
for (j = 0; j < font_patterns->nfont; j++)
|
for (j = 0; j < font_patterns->nfont; j++)
|
||||||
{
|
{
|
||||||
FcPattern *font_pattern;
|
FcPattern *font_pattern;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fcint.h"
|
#include "fcint.h"
|
||||||
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -395,6 +396,9 @@ FcFontRenderPrepare (FcConfig *config,
|
||||||
FcValue v;
|
FcValue v;
|
||||||
FcResult result;
|
FcResult result;
|
||||||
|
|
||||||
|
assert (pat != NULL);
|
||||||
|
assert (font != NULL);
|
||||||
|
|
||||||
new = FcPatternCreate ();
|
new = FcPatternCreate ();
|
||||||
if (!new)
|
if (!new)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -514,6 +518,10 @@ FcFontSetMatch (FcConfig *config,
|
||||||
{
|
{
|
||||||
FcPattern *best;
|
FcPattern *best;
|
||||||
|
|
||||||
|
assert (sets != NULL);
|
||||||
|
assert (p != NULL);
|
||||||
|
assert (result != NULL);
|
||||||
|
|
||||||
if (!config)
|
if (!config)
|
||||||
{
|
{
|
||||||
config = FcConfigGetCurrent ();
|
config = FcConfigGetCurrent ();
|
||||||
|
@ -536,6 +544,9 @@ FcFontMatch (FcConfig *config,
|
||||||
int nsets;
|
int nsets;
|
||||||
FcPattern *best;
|
FcPattern *best;
|
||||||
|
|
||||||
|
assert (p != NULL);
|
||||||
|
assert (result != NULL);
|
||||||
|
|
||||||
if (!config)
|
if (!config)
|
||||||
{
|
{
|
||||||
config = FcConfigGetCurrent ();
|
config = FcConfigGetCurrent ();
|
||||||
|
@ -672,6 +683,19 @@ FcFontSetSort (FcConfig *config,
|
||||||
FcBool *patternLangSat;
|
FcBool *patternLangSat;
|
||||||
FcValue patternLang;
|
FcValue patternLang;
|
||||||
|
|
||||||
|
assert (sets != NULL);
|
||||||
|
assert (p != NULL);
|
||||||
|
assert (result != NULL);
|
||||||
|
|
||||||
|
/* There are some implementation that relying on the result of
|
||||||
|
* "result" to check if the return value of FcFontSetSort
|
||||||
|
* is valid or not.
|
||||||
|
* So we should initialize it to the conservative way since
|
||||||
|
* this function doesn't return NULL anymore.
|
||||||
|
*/
|
||||||
|
if (result)
|
||||||
|
*result = FcResultNoMatch;
|
||||||
|
|
||||||
if (FcDebug () & FC_DBG_MATCH)
|
if (FcDebug () & FC_DBG_MATCH)
|
||||||
{
|
{
|
||||||
printf ("Sort ");
|
printf ("Sort ");
|
||||||
|
@ -686,7 +710,7 @@ FcFontSetSort (FcConfig *config,
|
||||||
nnodes += s->nfont;
|
nnodes += s->nfont;
|
||||||
}
|
}
|
||||||
if (!nnodes)
|
if (!nnodes)
|
||||||
goto bail0;
|
return FcFontSetCreate ();
|
||||||
|
|
||||||
for (nPatternLang = 0;
|
for (nPatternLang = 0;
|
||||||
FcPatternGet (p, FC_LANG, nPatternLang, &patternLang) == FcResultMatch;
|
FcPatternGet (p, FC_LANG, nPatternLang, &patternLang) == FcResultMatch;
|
||||||
|
@ -822,6 +846,9 @@ FcFontSort (FcConfig *config,
|
||||||
FcFontSet *sets[2];
|
FcFontSet *sets[2];
|
||||||
int nsets;
|
int nsets;
|
||||||
|
|
||||||
|
assert (p != NULL);
|
||||||
|
assert (result != NULL);
|
||||||
|
|
||||||
if (!config)
|
if (!config)
|
||||||
{
|
{
|
||||||
config = FcConfigGetCurrent ();
|
config = FcConfigGetCurrent ();
|
||||||
|
|
Loading…
Reference in New Issue