]> granicus.if.org Git - imagemagick/commitdiff
Eliminate hang when clearing the image stack
authorCristy <urban-warrior@imagemagick.org>
Wed, 30 Mar 2016 14:29:30 +0000 (10:29 -0400)
committerCristy <urban-warrior@imagemagick.org>
Wed, 30 Mar 2016 14:29:30 +0000 (10:29 -0400)
MagickWand/magick-cli.c

index 3086dcf086ac08a541eeb2d59db1ccbe699df323..b4ad33bded56b31c5980ad335b1fe9e470cb0564 100644 (file)
@@ -796,9 +796,11 @@ Magick_Command_Cleanup:
 
   /* recover original image_info and clean up stacks
      FUTURE: "-reset stacks" option  */
-  while (cli_wand->image_list_stack != (Stack *) NULL)
+  while ((cli_wand->image_list_stack != (Stack *) NULL) &&
+         (cli_wand->image_list_stack->next != (Stack *) NULL))
     CLIOption(cli_wand,")");
-  while (cli_wand->image_info_stack != (Stack *) NULL)
+  while ((cli_wand->image_info_stack != (Stack *) NULL) &&
+         (cli_wand->image_info_stack->next != (Stack *) NULL))
     CLIOption(cli_wand,"}");
 
   /* assert we have recovered the original structures */