From 6ef3cb2a758a3dd806df968e89a9fd7c51fed4bd Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 15 Apr 2022 20:22:51 -0400 Subject: [PATCH] eliminate Coverity defects --- coders/dcm.c | 10 ++++++---- coders/png.c | 6 ++---- coders/psd.c | 2 +- coders/xps.c | 15 --------------- magick/quantum-export.c | 15 +++++++++------ 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/coders/dcm.c b/coders/dcm.c index f1a2bc9e43..0876236b05 100644 --- a/coders/dcm.c +++ b/coders/dcm.c @@ -3023,11 +3023,13 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception) greenmap=(int *) RelinquishMagickMemory(greenmap); \ if (redmap != (int *) NULL) \ redmap=(int *) RelinquishMagickMemory(redmap); \ - if (stream_info->offsets != (ssize_t *) NULL) \ - stream_info->offsets=(ssize_t *) RelinquishMagickMemory( \ - stream_info->offsets); \ if (stream_info != (DCMStreamInfo *) NULL) \ - stream_info=(DCMStreamInfo *) RelinquishMagickMemory(stream_info); \ + { \ + if (stream_info->offsets != (ssize_t *) NULL) \ + stream_info->offsets=(ssize_t *) RelinquishMagickMemory( \ + stream_info->offsets); \ + stream_info=(DCMStreamInfo *) RelinquishMagickMemory(stream_info); \ + } \ if (stack != (LinkedListInfo *) NULL) \ stack=DestroyLinkedList(stack,RelinquishMagickMemory); \ ThrowReaderException((exception),(message)); \ diff --git a/coders/png.c b/coders/png.c index e50515f111..a6de29a76b 100644 --- a/coders/png.c +++ b/coders/png.c @@ -12792,10 +12792,8 @@ static MagickBooleanType WriteOneJNGImage(MngInfo *mng_info, &image->exception); if (blob == (unsigned char *) NULL) { - if (jpeg_image != (Image *)NULL) - jpeg_image=DestroyImage(jpeg_image); - if (jpeg_image_info != (ImageInfo *)NULL) - jpeg_image_info=DestroyImageInfo(jpeg_image_info); + jpeg_image=DestroyImage(jpeg_image); + jpeg_image_info=DestroyImageInfo(jpeg_image_info); return(MagickFalse); } jng_alpha_sample_depth=8; diff --git a/coders/psd.c b/coders/psd.c index eedcf3782d..40d6ab0bb7 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -1876,7 +1876,7 @@ static MagickBooleanType ReadPSDLayersInternal(Image *image, /* Layer name. */ - length=(MagickSizeType) (unsigned char) ReadBlobByte(image); + length=(MagickSizeType) ((unsigned char) ReadBlobByte(image)); combined_length+=length+1; if (length > 0) (void) ReadBlob(image,(size_t) length++,layer_info[i].name); diff --git a/coders/xps.c b/coders/xps.c index 2eb9668e10..2f2cd8b120 100644 --- a/coders/xps.c +++ b/coders/xps.c @@ -329,21 +329,6 @@ static Image *ReadXPSImage(const ImageInfo *image_info,ExceptionInfo *exception) break; AppendImageToList(&postscript_image,next); } - else - for (i=1; ; i++) - { - (void) InterpretImageFilename(image_info,image,filename,(int) i, - read_info->filename); - if (IsGhostscriptRendered(read_info->filename) == MagickFalse) - break; - read_info->blob=NULL; - read_info->length=0; - next=ReadImage(read_info,exception); - (void) RelinquishUniqueFileResource(read_info->filename); - if (next == (Image *) NULL) - break; - AppendImageToList(&postscript_image,next); - } (void) RelinquishUniqueFileResource(filename); read_info=DestroyImageInfo(read_info); if (postscript_image == (Image *) NULL) diff --git a/magick/quantum-export.c b/magick/quantum-export.c index 1c1b306255..bc42a630b8 100644 --- a/magick/quantum-export.c +++ b/magick/quantum-export.c @@ -3868,8 +3868,9 @@ MagickExport size_t ExportQuantumPixels(const Image *image, /* Associate alpha. */ - q=GetAuthenticPixelQueue(image); - if (image_view != (CacheView *) NULL) + if (image_view == (CacheView *) NULL) + q=GetAuthenticPixelQueue(image); + else q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view); for (x=0; x < (ssize_t) image->columns; x++) { @@ -3888,9 +3889,10 @@ MagickExport size_t ExportQuantumPixels(const Image *image, PixelPacket *magick_restrict q; - q=GetAuthenticPixelQueue(image); - if (image_view != (CacheView *) NULL) + if (image_view == (CacheView *) NULL) q=GetAuthenticPixelQueue(image); + else + q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view); for (x=0; x < (ssize_t) number_pixels; x++) { quantum=GetPixelRed(q); @@ -4028,8 +4030,9 @@ MagickExport size_t ExportQuantumPixels(const Image *image, PixelPacket *magick_restrict q; - q=GetAuthenticPixelQueue(image); - if (image_view != (CacheView *) NULL) + if (image_view == (CacheView *) NULL) + q=GetAuthenticPixelQueue(image); + else q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view); for (x=0; x < (ssize_t) number_pixels; x++) {