From cc04a16f0c94cc9b0d18d79ead290f12c3cc4f42 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Fri, 21 Sep 2012 11:55:23 +0800 Subject: [PATCH] Backport fix for Bug#12463 from trunk. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * image.c (define_image_type): Avoid adding duplicate types to image_types. Suggested by Jörg Walter. --- src/ChangeLog | 5 +++++ src/image.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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; -- 2.39.2