From: Chong Yidong Date: Fri, 21 Sep 2012 03:52:23 +0000 (+0800) Subject: Fix list duplication error in define_image_type. X-Git-Tag: emacs-24.2.90~269^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=09c01941f40d1f334435f3aee8f4a66459e47866;p=emacs.git Fix list duplication error in define_image_type. * image.c (define_image_type): Avoid adding duplicate types to image_types. Suggested by Jörg Walter. Fixes: debbugs:12463 --- diff --git a/src/ChangeLog b/src/ChangeLog index f3b8b2108e1..31db282c6e3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2012-09-21 Chong Yidong + + * image.c (define_image_type): Avoid adding duplicate types to + image_types (Bug#12463). Suggested by Jörg Walter. + 2012-09-21 YAMAMOTO Mitsuharu * unexmacosx.c: Define LC_DATA_IN_CODE if not defined. diff --git a/src/image.c b/src/image.c index 8fc1c8637eb..8d690df8abb 100644 --- a/src/image.c +++ b/src/image.c @@ -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;