From: Chong Yidong Date: Fri, 21 Sep 2012 03:55:23 +0000 (+0800) Subject: Backport fix for Bug#12463 from trunk. X-Git-Tag: emacs-24.2.90~244^2~44^2~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cc04a16f0c94cc9b0d18d79ead290f12c3cc4f42;p=emacs.git Backport fix for Bug#12463 from trunk. * image.c (define_image_type): Avoid adding duplicate types to image_types. Suggested by Jörg Walter. --- diff --git a/src/ChangeLog b/src/ChangeLog index afaa7fd776e..15b47934424 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-20 YAMAMOTO Mitsuharu * unexmacosx.c: Define LC_DATA_IN_CODE if not defined. diff --git a/src/image.c b/src/image.c index 73490fe2865..fd99bdfc950 100644 --- a/src/image.c +++ b/src/image.c @@ -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;