From: Dirk Lemstra Date: Thu, 9 Feb 2017 20:53:16 +0000 (+0100) Subject: Fixed memory leak when creating nested exceptions in Magick++. X-Git-Tag: 7.0.4-8~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=425344a2b019d080fc7b4069ae79e5de4dd49fd6;p=imagemagick Fixed memory leak when creating nested exceptions in Magick++. --- diff --git a/ChangeLog b/ChangeLog index 8fd79fb16..312a7fd99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -2017-03-07 7.0.4-9 Cristy +2017-02-09 7.0.4-8 Dirk Lemstra + * Fixed memory leak when creating nested exceptions in Magick++ (reference + https://www.imagemagick.org/discourse-server/viewtopic.php?f=23&p=142634) + +2017-02-07 7.0.4-8 Cristy * Unbreak build without JPEG support (reference https://github.com/ImageMagick/ImageMagick/pull/373). diff --git a/Magick++/lib/Exception.cpp b/Magick++/lib/Exception.cpp index e2b509895..056f87b5a 100644 --- a/Magick++/lib/Exception.cpp +++ b/Magick++/lib/Exception.cpp @@ -842,6 +842,7 @@ MagickPPExport void Magick::throwException(ExceptionInfo *exception_, message=formatExceptionMessage(exception_); nestedException=(Exception *) NULL; + q=(Exception *) NULL; LockSemaphoreInfo(exception_->semaphore); if (exception_->exceptions != (void *) NULL) { @@ -856,12 +857,18 @@ MagickPPExport void Magick::throwException(ExceptionInfo *exception_, exception_->description) != 0)) { if (nestedException == (Exception *) NULL) - nestedException=createException(p); + { + nestedException=createException(p); + q=nestedException; + } else { - q=createException(p); - nestedException->nested(q); - nestedException=q; + Exception + *r; + + r=createException(p); + q->nested(r); + q=r; } } }