From 6da26928029c4598e75a344d57c08ca85dd95f2a Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Mon, 19 Aug 2013 16:52:52 +0200 Subject: [PATCH] * 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. --- src/ChangeLog | 5 +++++ src/image.c | 28 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) 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; + } } } -- 2.11.4.GIT