From: Dirk Lemstra Date: Sun, 4 Mar 2018 22:18:37 +0000 (+0100) Subject: Fixed memory leaks (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6075). X-Git-Tag: 7.0.7-26~89 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4cc9c1d0644f005a0ed57f75f27e6147939e8aad;p=imagemagick Fixed memory leaks (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6075). --- diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp index a711b3027..af953aedc 100644 --- a/Magick++/lib/Image.cpp +++ b/Magick++/lib/Image.cpp @@ -4877,6 +4877,8 @@ void Magick::Image::write(Blob *blob_) data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo); if (length > 0) blob_->updateNoCopy(data,length,Blob::MallocAllocator); + else + data=RelinquishMagickMemory(data); ThrowImageException; } @@ -4894,6 +4896,8 @@ void Magick::Image::write(Blob *blob_,const std::string &magick_) data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo); if (length > 0) blob_->updateNoCopy(data,length,Blob::MallocAllocator); + else + data=RelinquishMagickMemory(data); ThrowImageException; } @@ -4913,6 +4917,8 @@ void Magick::Image::write(Blob *blob_,const std::string &magick_, data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo); if (length > 0) blob_->updateNoCopy(data,length,Blob::MallocAllocator); + else + data=RelinquishMagickMemory(data); ThrowImageException; }