From fc3ab0812edef903bbb2473c0ee652ddfd04fe5c Mon Sep 17 00:00:00 2001
From: Dirk Lemstra <dirk@lemstra.org>
Date: Fri, 27 Jun 2025 14:51:57 +0200
Subject: [PATCH] Fixed memory leak when entering StreamImage multiple times.

---
 MagickCore/stream.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MagickCore/stream.c b/MagickCore/stream.c
index 99ccf0d0e9d..0e0171d3691 100644
--- a/MagickCore/stream.c
+++ b/MagickCore/stream.c
@@ -1321,7 +1321,8 @@ MagickExport Image *StreamImage(const ImageInfo *image_info,
       image_info->filename);
   read_info=CloneImageInfo(image_info);
   stream_info->image_info=image_info;
-  stream_info->quantum_info=AcquireQuantumInfo(image_info,(Image *) NULL);
+  if (stream_info->quantum_info == (QuantumInfo *) NULL)
+    stream_info->quantum_info=AcquireQuantumInfo(image_info,(Image *) NULL);
   if (stream_info->quantum_info == (QuantumInfo *) NULL)
     {
       read_info=DestroyImageInfo(read_info);

