From 1fbed78912c830ccd82eecdb8a1db4882abb8276 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Tue, 30 Jan 2018 07:16:47 +0100 Subject: [PATCH] Fixed memory leak reported in #964 --- coders/dcm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coders/dcm.c b/coders/dcm.c index 5f9cb02c7..2e339fc9b 100644 --- a/coders/dcm.c +++ b/coders/dcm.c @@ -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) -- 2.40.0