Construct empty constant charsets correctly (using null pointers)

This commit is contained in:
Keith Packard 2002-06-26 22:56:51 +00:00
parent c552f59ba2
commit 5c7fb8274c
1 changed files with 13 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.10 2002/05/31 04:42:42 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.12 2002/06/21 06:14:45 keithp Exp $
* *
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -948,10 +948,18 @@ FcNameParseBuildSet (FcCharSet *fcs)
ent->set.ref = 0; ent->set.ref = 0;
ent->set.constant = FcTrue; ent->set.constant = FcTrue;
ent->set.num = fcs->num; ent->set.num = fcs->num;
ent->set.leaves = (FcCharLeaf **) (ent + 1); if (fcs->num)
ent->set.numbers = (FcChar16 *) (ent->set.leaves + fcs->num); {
memcpy (ent->set.leaves, fcs->leaves, fcs->num * sizeof (FcCharLeaf *)); ent->set.leaves = (FcCharLeaf **) (ent + 1);
memcpy (ent->set.numbers, fcs->numbers, fcs->num * sizeof (FcChar16)); ent->set.numbers = (FcChar16 *) (ent->set.leaves + fcs->num);
memcpy (ent->set.leaves, fcs->leaves, fcs->num * sizeof (FcCharLeaf *));
memcpy (ent->set.numbers, fcs->numbers, fcs->num * sizeof (FcChar16));
}
else
{
ent->set.leaves = 0;
ent->set.numbers = 0;
}
ent->hash = hash; ent->hash = hash;
ent->next = *bucket; ent->next = *bucket;