Avoid crashes if config files contain junk.

If ~/.fonts.conf contains:

  <edit mode="assign_replace" name="spacing">
     <int>mono</int>
       </edit>

fontconfig crashes:

    mfabian@magellan:~$ fc-match sans
        Fontconfig error: "~/.fonts.conf", line 46: "mono": not a valid
	integer
	    セグメンテーション違反です (core dumped)
	        mfabian@magellan:~$

Of course the above is nonsense, “mono” is no valid integer indeed.

But I think nevertheless fontconfig should not crash in that case.

The problem was caused by partially truncated expression trees caused by
parse errors -- typechecking these walked the tree without verifying the
integrity of the structure. Of course, the whole tree will be discarded
shortly after being loaded as it contained an error.
This commit is contained in:
Mike FABIAN 2007-10-18 05:44:28 -07:00 committed by Keith Packard
parent fa9a7448d8
commit 07e646cc84
1 changed files with 4 additions and 0 deletions

View File

@ -558,6 +558,10 @@ FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type)
const FcObjectType *o;
const FcConstant *c;
/* If parsing the expression failed, some nodes may be NULL */
if (!expr)
return;
switch (expr->op) {
case FcOpInteger:
case FcOpDouble: