[prev in list] [next in list] [prev in thread] [next in thread]
List: graphicsmagick-commit
Subject: [GM-commit] GraphicsMagick: AVS: Fix memory leak in error path.
From: GraphicsMagick Commits <graphicsmagick-commit () lists ! sourceforge ! net>
Date: 2017-09-30 22:27:25
Message-ID: mailman.1807.1506810455.14213.graphicsmagick-commit () lists ! sourceforge ! net
[Download RAW message or body]
changeset d58b78194747 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=d58b78194747
summary: AVS: Fix memory leak in error path.
diffstat:
ChangeLog | 3 +++
coders/avs.c | 21 +++++++++++----------
www/Changelog.html | 2 ++
3 files changed, 16 insertions(+), 10 deletions(-)
diffs (89 lines):
diff -r 2a84c4f0f453 -r d58b78194747 ChangeLog
--- a/ChangeLog Sat Sep 30 17:17:39 2017 -0500
+++ b/ChangeLog Sat Sep 30 17:27:23 2017 -0500
@@ -1,5 +1,8 @@
2017-09-30 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
+ * coders/avs.c (ReadAVSImage): Fix SourceForge issue #499 "memory
+ leak in avs.c".
+
* coders/cmyk.c (ReadCMYKImage): Fix SourceForge issue #498
"memory leak in cmyk.c".
diff -r 2a84c4f0f453 -r d58b78194747 coders/avs.c
--- a/coders/avs.c Sat Sep 30 17:17:39 2017 -0500
+++ b/coders/avs.c Sat Sep 30 17:27:23 2017 -0500
@@ -83,6 +83,11 @@
*/
#define AVS_WIDTH_LIMIT 65536UL /* Artificially limit width to 64K pixels */
#define AVS_HEIGHT_LIMIT 65536UL /* Artificially limit height to 64K pixels */
+#define ThrowAVSReaderException(code_,reason_,image_) \
+ { \
+ MagickFreeMemory(pixels); \
+ ThrowReaderException(code_,reason_,image_); \
+ }
static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
Image
@@ -101,7 +106,7 @@
*p;
unsigned char
- *pixels;
+ *pixels = (unsigned char *) NULL;
unsigned int
status;
@@ -127,7 +132,7 @@
width=ReadBlobMSBLong(image);
height=ReadBlobMSBLong(image);
if (EOFBlob(image))
- ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+ ThrowAVSReaderException(CorruptImageError,UnexpectedEndOfFile,image);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"AVS dimensions %ldx%ld",width,height);
@@ -137,7 +142,7 @@
incredibly huge allocations.
*/
if ((width > AVS_WIDTH_LIMIT) || (height > AVS_HEIGHT_LIMIT))
- ThrowReaderException(CoderError,ImageColumnOrRowSizeIsNotSupported,image);
+ ThrowAVSReaderException(CoderError,ImageColumnOrRowSizeIsNotSupported,image);
do
{
@@ -154,19 +159,15 @@
if (image->scene >= (image_info->subimage+image_info->subrange-1))
break;
if (CheckImagePixelLimits(image, exception) != MagickPass)
- ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+ ThrowAVSReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
pixels=MagickAllocateArray(unsigned char *,image->columns,4);
if (pixels == (unsigned char *) NULL)
- ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+ ThrowAVSReaderException(ResourceLimitError,MemoryAllocationFailed,image);
row_bytes=4*image->columns;
for (y=0; y < (long) image->rows; y++)
{
if (ReadBlob(image,row_bytes,pixels) != row_bytes)
- {
- ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
- image->filename);
- status=MagickFail;
- }
+ ThrowAVSReaderException(CorruptImageError,UnexpectedEndOfFile,image);
p=pixels;
q=SetImagePixels(image,0,y,image->columns,1);
if (q == (PixelPacket *) NULL)
diff -r 2a84c4f0f453 -r d58b78194747 www/Changelog.html
--- a/www/Changelog.html Sat Sep 30 17:17:39 2017 -0500
+++ b/www/Changelog.html Sat Sep 30 17:27:23 2017 -0500
@@ -38,6 +38,8 @@
<p>2017-09-30 Bob Friesenhahn <<a class="reference external" \
href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span> \
4;</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p>
<blockquote>
<ul class="simple">
+<li>coders/avs.c (ReadAVSImage): Fix SourceForge issue #499 "memory
+leak in avs.c".</li>
<li>coders/cmyk.c (ReadCMYKImage): Fix SourceForge issue #498
"memory leak in cmyk.c".</li>
<li>coders/cut.c (ReadCUTImage): Fix SourceForge issue #497 "memory
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Graphicsmagick-commit mailing list
Graphicsmagick-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-commit
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic