File ImageMagick-CVE-2022-1114.patch of Package ImageMagick

Index: ImageMagick-7.1.0-9/coders/dcm.c
===================================================================
--- ImageMagick-7.1.0-9.orig/coders/dcm.c
+++ ImageMagick-7.1.0-9/coders/dcm.c
@@ -3243,18 +3243,17 @@ static Image *ReadDCMImage(const ImageIn
           RelinquishMagickMemory(info_copy);
         }
 
-      /*
-        If we're entering a sequence, push the current image parameters onto
-        the stack, so we can restore them at the end of the sequence.
-      */
       if (strcmp(explicit_vr,"SQ") == 0)
         {
-          info_copy=(DCMInfo *) AcquireMagickMemory(sizeof(info));
-          memcpy(info_copy,&info,sizeof(info));
-          AppendValueToLinkedList(stack,info_copy);
+          /*
+            If we're entering a sequence, push the current image parameters
+            onto the stack, so we can restore them at the end of the sequence.
+          */
+          DCMInfo *clone_info=(DCMInfo *) AcquireMagickMemory(sizeof(info));
+          memcpy(clone_info,&info,sizeof(info));
+          AppendValueToLinkedList(stack,clone_info);
           sequence_depth++;
         }
-
       datum=0;
       if (quantum == 4)
         {
openSUSE Build Service is sponsored by