+2006-04-11 Ming Zhao <ming@gentoo.org>
+ reviewed by: plam
+
+ * src/fcname.c (FcObjectToPtrLookup):
+
+ Fix bad behaviour on realloc resulting in crash.
+
2006-04-11 Patrick Lam <plam@mit.edu>
* src/fccache.c (FcGlobalCacheReadDir):
{
FcObjectPtr i = 0, n;
const FcObjectTypeList *l;
- FcObjectType *t = _FcUserObjectNames;
+ FcObjectType *t = _FcUserObjectNames, *origNames;
+ FcBool replace;
for (l = _FcObjectTypes; l; l = l->next)
{
/* 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)
break;
}
+ replace = l && l->types == _FcUserObjectNames;
if (!_FcUserObjectNames ||
- (l && l->types == _FcUserObjectNames && user_obj_alloc < l->ntypes))
+ (replace && user_obj_alloc <= l->ntypes))
{
int nt = user_obj_alloc + 4;
- FcObjectType * t = realloc (_FcUserObjectNames,
+ FcObjectType * tt = realloc (_FcUserObjectNames,
nt * sizeof (FcObjectType));
- if (!t)
+ if (!tt)
return 0;
- _FcUserObjectNames = t;
+ _FcUserObjectNames = tt;
user_obj_alloc = nt;
}
- if (l && l->types == _FcUserObjectNames)
+ if (replace)
{
n = l->ntypes;
FcNameUnregisterObjectTypesFree (l->types, l->ntypes, FcFalse);
for (l = _FcObjectTypes; l; l = l->next)
{
- if (l->types == _FcUserObjectNames)
+ if (l->types == origNames)
{
t = (FcObjectType *)l->types;
break;