From 8cfa0bbc822169c5c2dae8a0e089c225c5944558 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Fri, 14 Apr 2006 18:35:16 +0000 Subject: [PATCH] Fix Gecko-exposed segfault from my last hack to FcObjectToPtrLookup. Simplify code and get things straight. --- ChangeLog | 6 ++++++ src/fcname.c | 20 +++++--------------- 2 files changed, 11 insertions(+), 15 deletions(-) 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; } -- 2.39.5