]> granicus.if.org Git - imagemagick/commitdiff
Fixed memory leak reported in #964
authorDirk Lemstra <dirk@git.imagemagick.org>
Tue, 30 Jan 2018 06:16:47 +0000 (07:16 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Tue, 30 Jan 2018 06:17:10 +0000 (07:17 +0100)
coders/dcm.c

index 5f9cb02c71ce2440774dd03ad2f07eb5a11affbf..2e339fc9b8a897791139d2f76690b4eddd1cf45d 100644 (file)
@@ -3580,6 +3580,8 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               break;
             colors=(size_t) (length/2);
             datum=(int) colors;
+            if (redmap != (int *) NULL)
+              redmap=(int *) RelinquishMagickMemory(redmap);
             redmap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*redmap));
             if (redmap == (int *) NULL)
@@ -3608,6 +3610,8 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               break;
             colors=(size_t) (length/2);
             datum=(int) colors;
+            if (greenmap != (int *) NULL)
+              greenmap=(int *) RelinquishMagickMemory(greenmap);
             greenmap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*greenmap));
             if (greenmap == (int *) NULL)
@@ -3636,6 +3640,8 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               break;
             colors=(size_t) (length/2);
             datum=(int) colors;
+            if (bluemap != (int *) NULL)
+              bluemap=(int *) RelinquishMagickMemory(bluemap);
             bluemap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*bluemap));
             if (bluemap == (int *) NULL)