From: Patrick Lam Date: Fri, 14 Apr 2006 18:35:16 +0000 (+0000) Subject: Fix Gecko-exposed segfault from my last hack to FcObjectToPtrLookup. X-Git-Tag: fc-2_3_95~9 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=8cfa0bbc822169c5c2dae8a0e089c225c5944558;p=fontconfig.git Fix Gecko-exposed segfault from my last hack to FcObjectToPtrLookup. Simplify code and get things straight. --- diff --git a/ChangeLog b/ChangeLog index be0b500..fc720f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-14 Patrick Lam + * 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 * fonts.conf.in: diff --git a/src/fcname.c b/src/fcname.c index aa49475..ed09597 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -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; }