]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix list duplication error in define_image_type.
authorChong Yidong <cyd@gnu.org>
Fri, 21 Sep 2012 03:52:23 +0000 (11:52 +0800)
committerChong Yidong <cyd@gnu.org>
Fri, 21 Sep 2012 03:52:23 +0000 (11:52 +0800)
* image.c (define_image_type): Avoid adding duplicate types to
image_types.  Suggested by Jörg Walter.

Fixes: debbugs:12463
src/ChangeLog
src/image.c

index f3b8b2108e1f27bc2f71f302b3d729926f92792d..31db282c6e3c1cf1ea7621a7afa584392291872a 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-21  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
        * unexmacosx.c: Define LC_DATA_IN_CODE if not defined.
index 8fc1c8637ebb5e93afd16bb163151e3e481baacb..8d690df8abbe81235897af67d7f8df4a8746e2ba 100644 (file)
@@ -590,9 +590,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 = xmalloc (sizeof *p);
+      p = xmalloc (sizeof *p);
       *p = *type;
       p->next = image_types;
       image_types = p;