]> git.wh0rd.org Git - fontconfig.git/commitdiff
Fix Gecko-exposed segfault from my last hack to FcObjectToPtrLookup.
authorPatrick Lam <plam@MIT.EDU>
Fri, 14 Apr 2006 18:35:16 +0000 (18:35 +0000)
committerPatrick Lam <plam@MIT.EDU>
Fri, 14 Apr 2006 18:35:16 +0000 (18:35 +0000)
    Simplify code and get things straight.

ChangeLog
src/fcname.c

index be0b5005b9173f9457805965493d07e36e2d9d1a..fc720f06248198204317d2f31b273fbc917f92f1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-14  Patrick Lam  <plam@mit.edu>
+       * src/fcname.c (FcObjectToPtrLookup):
+
+       Fix Gecko-exposed segfault from my last hack to
+       FcObjectToPtrLookup.  Simplify code and get things straight.
+
 2006-04-14  Patrick Lam  <plam@mit.edu>
        * fonts.conf.in:
 
index aa494751ac46220775e058f632c0253fe122e658..ed09597d94a5265a092f7f3b6d536393740a2cd0 100644 (file)
@@ -193,7 +193,7 @@ FcObjectToPtrLookup (const char * object)
 {
     FcObjectPtr                    i = 0, n;
     const FcObjectTypeList  *l;
-    FcObjectType           *t = _FcUserObjectNames, *origNames;
+    FcObjectType           *t = _FcUserObjectNames;
     FcBool                 replace;
 
     for (l = _FcObjectTypes; l; l = l->next)
@@ -203,7 +203,7 @@ FcObjectToPtrLookup (const char * object)
            t = (FcObjectType *)&l->types[i];
            if (!strcmp (object, t->object))
            {
-               if (l == (FcObjectTypeList*)_FcUserObjectNames)
+               if (l->types == _FcUserObjectNames)
                     return -i;
                else
                    return l->basic_offset + i;
@@ -213,7 +213,6 @@ FcObjectToPtrLookup (const char * object)
 
     /* We didn't match.  Look for the application's FcObjectTypeList
      * and replace it in-place. */
-    origNames = _FcUserObjectNames;
     for (l = _FcObjectTypes; l; l = l->next)
     {
        if (l->types == _FcUserObjectNames)
@@ -243,20 +242,11 @@ FcObjectToPtrLookup (const char * object)
 
     FcNameRegisterObjectTypes (_FcUserObjectNames, n+1);
 
-    for (l = _FcObjectTypes; l; l = l->next)
-    {
-       if (l->types == origNames)
-       {
-           t = (FcObjectType *)l->types;
-           break;
-       }
-    }
-
-    if (!t)
+    if (!_FcUserObjectNames)
        return 0;
 
-    t[n].object = object;
-    t[n].type = FcTypeVoid;
+    _FcUserObjectNames[n].object = object;
+    _FcUserObjectNames[n].type = FcTypeVoid;
 
     return -n;
 }