]> git.wh0rd.org - fontconfig.git/commitdiff
Construct empty constant charsets correctly (using null pointers)
authorKeith Packard <keithp@keithp.com>
Wed, 26 Jun 2002 22:56:51 +0000 (22:56 +0000)
committerKeith Packard <keithp@keithp.com>
Wed, 26 Jun 2002 22:56:51 +0000 (22:56 +0000)
src/fccharset.c

index 86c59adfff65c3fe3b22a19afa812abffd3dfb55..cc471264429dcea61c2009335fbd891fee58c1ec 100644 (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.
  *
@@ -948,10 +948,18 @@ FcNameParseBuildSet (FcCharSet *fcs)
     ent->set.ref = 0;
     ent->set.constant = FcTrue;
     ent->set.num = fcs->num;
-    ent->set.leaves = (FcCharLeaf **) (ent + 1);
-    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));
+    if (fcs->num)
+    {
+       ent->set.leaves = (FcCharLeaf **) (ent + 1);
+       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->next = *bucket;