From: Lars Magne Ingebrigtsen Date: Mon, 19 Aug 2013 14:52:52 +0000 (+0200) Subject: * image.c (imagemagick_get_animation_cache): Don't segfault on each invocation. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~174 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6da26928029c4598e75a344d57c08ca85dd95f2a;p=emacs.git * image.c (imagemagick_get_animation_cache): Don't segfault on each invocation. Bug introduced by 2013-08-19T07:01:37Z!eggert@cs.ucla.edu, which obviously hadn't even been tested once. --- diff --git a/src/ChangeLog b/src/ChangeLog index c5a6f4d19c3..716b1177fd1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-08-19 Lars Magne Ingebrigtsen + + * image.c (imagemagick_get_animation_cache): Don't segfault on + each invocation. + 2013-08-19 Paul Eggert * image.c: Fix animation cache signature memory leak. diff --git a/src/image.c b/src/image.c index 68d78fc9eef..ec89ee076d9 100644 --- a/src/image.c +++ b/src/image.c @@ -7927,23 +7927,27 @@ imagemagick_get_animation_cache (MagickWand *wand) { char *signature = MagickGetImageSignature (wand); struct animation_cache *cache; - struct animation_cache **pcache = &animation_cache; + struct animation_cache **pcache; imagemagick_prune_animation_cache (); - cache = animation_cache; - for (pcache = &animation_cache; *pcache; pcache = &cache->next) + if (! animation_cache) + animation_cache = cache = imagemagick_create_cache (signature); + else { - cache = *pcache; - if (! cache) - { - *pcache = cache = imagemagick_create_cache (signature); - break; - } - if (strcmp (signature, cache->signature) == 0) + for (pcache = &animation_cache; *pcache; pcache = &cache->next) { - DestroyString (signature); - break; + cache = *pcache; + if (! cache) + { + animation_cache = cache = imagemagick_create_cache (signature); + break; + } + if (strcmp (signature, cache->signature) == 0) + { + DestroyString (signature); + break; + } } }