[Fontconfig] fontconfig: Branch 'master' - 3 commits

Akira TAGOH tagoh at kemper.freedesktop.org
Fri May 22 04:53:43 PDT 2015


 src/fcobjs.c |   22 +++++++++++++++++++++-
 src/fcxml.c  |    3 ++-
 2 files changed, 23 insertions(+), 2 deletions(-)

New commits:
commit 09edd84cf8e8bd1f6062c8803316327e662fdbda
Author: Akira TAGOH <akira at tagoh.org>
Date:   Fri May 22 20:51:21 2015 +0900

    Detect the overflow for the object ID
    
    Continue to increase the object id even after FcFini()
    and detect the overflow. that would be rather easier than
    reset the object id with the complicated mutex and atomic
    functions.
    
    This situation would be quite unlikely to happen though

diff --git a/src/fcobjs.c b/src/fcobjs.c
index 2895dc0..5e6b091 100644
--- a/src/fcobjs.c
+++ b/src/fcobjs.c
@@ -51,6 +51,8 @@ FcObjectFini (void)
 
 retry:
     ots = fc_atomic_ptr_get (&other_types);
+    if (!ots)
+	return;
     if (!fc_atomic_ptr_cmpexch (&other_types, ots, NULL))
 	goto retry;
 
@@ -68,6 +70,8 @@ static FcObjectType *
 _FcObjectLookupOtherTypeByName (const char *str, FcObject *id)
 {
     struct FcObjectOtherTypeInfo *ots, *ot;
+    static fc_atomic_int_t first_id = 0;
+    static FcBool overflow = FcFalse;
 
 retry:
     ots = fc_atomic_ptr_get (&other_types);
@@ -76,6 +80,11 @@ retry:
 	if (0 == strcmp (ot->object.object, str))
 	    break;
 
+    if (!ots)
+    {
+	first_id = fc_atomic_int_add (next_id, 0);
+	overflow = FcFalse;
+    }
     if (!ot)
     {
 	ot = malloc (sizeof (*ot));
@@ -84,14 +93,25 @@ retry:
 
 	ot->object.object = (char *) FcStrdup (str);
 	ot->object.type = FcTypeUnknown;
+    retry_id:
 	ot->id = fc_atomic_int_add (next_id, +1);
+	if (overflow && ot->id == first_id)
+	{
+	    fprintf (stderr, "Fontconfig error: No object ID to assign\n");
+	    abort ();
+	}
+	if (ot->id < (FC_MAX_BASE_OBJECT + FC_EXT_OBJ_INDEX))
+	{
+	    overflow = FcTrue;
+	    fc_atomic_ptr_cmpexch (&next_id, ot->id + 1, FC_MAX_BASE_OBJECT + FC_EXT_OBJ_INDEX + 1);
+	    goto retry_id;
+	}
 	ot->next = ots;
 
 	if (!fc_atomic_ptr_cmpexch (&other_types, ots, ot)) {
 	    if (ot->object.object)
 		free (ot->object.object);
 	    free (ot);
-	    fc_atomic_int_add (next_id, -1);
 	    goto retry;
 	}
     }
commit f053231186fc340b5365a59eea30db5af787877a
Author: Akira TAGOH <akira at tagoh.org>
Date:   Fri May 22 20:46:54 2015 +0900

    Fix a crash
    
    segfault happens when the config needs to be migrated to XDG's
    and no definition for include with prefix="xdg"

diff --git a/src/fcxml.c b/src/fcxml.c
index ba38203..d471569 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -2388,6 +2388,7 @@ FcParseInclude (FcConfigParse *parse)
         filename = FcConfigFilename(s);
 	if (deprecated == FcTrue &&
 	    filename != NULL &&
+	    userdir != NULL &&
 	    !FcFileIsLink (filename))
 	{
 	    if (FcFileIsDir (filename))
commit 249306fbd782570cf958675672d21cf12aa1f14e
Author: Akira TAGOH <akira at tagoh.org>
Date:   Fri May 22 20:45:05 2015 +0900

    Fix a typo

diff --git a/src/fcxml.c b/src/fcxml.c
index 1a68bc4..ba38203 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -2293,7 +2293,7 @@ FcParseInclude (FcConfigParse *parse)
     FcBool	    deprecated = FcFalse;
 #endif
     FcChar8	    *prefix = NULL, *p;
-    FcChar8	    userdir, userconf;
+    FcChar8	    *userdir = NULL, *userconf = NULL;
 
     s = FcStrBufDoneStatic (&parse->pstack->str);
     if (!s)


More information about the Fontconfig mailing list