]> code.delx.au - gnu-emacs/commitdiff
Backport fix for Bug#12463 from trunk.
authorChong Yidong <cyd@gnu.org>
Fri, 21 Sep 2012 03:55:23 +0000 (11:55 +0800)
committerChong Yidong <cyd@gnu.org>
Fri, 21 Sep 2012 03:55:23 +0000 (11:55 +0800)
* image.c (define_image_type): Avoid adding duplicate types to
image_types.  Suggested by Jörg Walter.

src/ChangeLog
src/image.c

index afaa7fd776ea26846f1d4d7ec5e5d48065e30b2d..15b47934424cad14a1864c9afb6d7b58ceeb1cb3 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-21  Chong Yidong  <cyd@gnu.org>
+
+       * image.c (define_image_type): Avoid adding duplicate types to
+       image_types (Bug#12463).  Suggested by Jörg Walter.
+
 2012-09-20  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
        * unexmacosx.c: Define LC_DATA_IN_CODE if not defined.
index 73490fe28659afbdd199e56dbbd6d206adbb400b..fd99bdfc950fcc559ce9a6caabb6ae5f3c45118b 100644 (file)
@@ -597,9 +597,15 @@ define_image_type (struct image_type *type, int loaded)
     success = Qnil;
   else
     {
+      struct image_type *p;
+      Lisp_Object target_type = *(type->type);
+      for (p = image_types; p; p = p->next)
+       if (EQ (*(p->type), target_type))
+         return Qt;
+
       /* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
          The initialized data segment is read-only.  */
-      struct image_type *p = (struct image_type *) xmalloc (sizeof *p);
+      p = (struct image_type *) xmalloc (sizeof *p);
       memcpy (p, type, sizeof *p);
       p->next = image_types;
       image_types = p;