Fix Gecko-exposed segfault from my last hack to FcObjectToPtrLookup.

Simplify code and get things straight.
This commit is contained in:
Patrick Lam 2006-04-14 18:35:16 +00:00
parent b43dbbdc92
commit 8cfa0bbc82
2 changed files with 11 additions and 15 deletions

View File

@ -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> 2006-04-14 Patrick Lam <plam@mit.edu>
* fonts.conf.in: * fonts.conf.in:

View File

@ -193,7 +193,7 @@ FcObjectToPtrLookup (const char * object)
{ {
FcObjectPtr i = 0, n; FcObjectPtr i = 0, n;
const FcObjectTypeList *l; const FcObjectTypeList *l;
FcObjectType *t = _FcUserObjectNames, *origNames; FcObjectType *t = _FcUserObjectNames;
FcBool replace; FcBool replace;
for (l = _FcObjectTypes; l; l = l->next) for (l = _FcObjectTypes; l; l = l->next)
@ -203,7 +203,7 @@ FcObjectToPtrLookup (const char * object)
t = (FcObjectType *)&l->types[i]; t = (FcObjectType *)&l->types[i];
if (!strcmp (object, t->object)) if (!strcmp (object, t->object))
{ {
if (l == (FcObjectTypeList*)_FcUserObjectNames) if (l->types == _FcUserObjectNames)
return -i; return -i;
else else
return l->basic_offset + i; return l->basic_offset + i;
@ -213,7 +213,6 @@ FcObjectToPtrLookup (const char * object)
/* We didn't match. Look for the application's FcObjectTypeList /* We didn't match. Look for the application's FcObjectTypeList
* and replace it in-place. */ * and replace it in-place. */
origNames = _FcUserObjectNames;
for (l = _FcObjectTypes; l; l = l->next) for (l = _FcObjectTypes; l; l = l->next)
{ {
if (l->types == _FcUserObjectNames) if (l->types == _FcUserObjectNames)
@ -243,20 +242,11 @@ FcObjectToPtrLookup (const char * object)
FcNameRegisterObjectTypes (_FcUserObjectNames, n+1); FcNameRegisterObjectTypes (_FcUserObjectNames, n+1);
for (l = _FcObjectTypes; l; l = l->next) if (!_FcUserObjectNames)
{
if (l->types == origNames)
{
t = (FcObjectType *)l->types;
break;
}
}
if (!t)
return 0; return 0;
t[n].object = object; _FcUserObjectNames[n].object = object;
t[n].type = FcTypeVoid; _FcUserObjectNames[n].type = FcTypeVoid;
return -n; return -n;
} }