From 3a177d8bfb7ed426c1e72aa865dd689bbcfbb20a Mon Sep 17 00:00:00 2001 From: ImageMagick Date: Sun, 7 Oct 2018 08:12:29 -0400 Subject: [PATCH] Revert "cleanup identical conditions (#1339)" (#1340) This reverts commit 192780734f3ab2b322f1add273dfe730ce15e04b. --- MagickCore/nt-base.c | 27 +++++++++++++++------------ MagickCore/prepress.c | 3 ++- MagickCore/quantize.c | 19 +++++++++++-------- MagickCore/xml-tree.c | 6 ++++-- coders/dds.c | 17 ++++++++++------- 5 files changed, 42 insertions(+), 30 deletions(-) diff --git a/MagickCore/nt-base.c b/MagickCore/nt-base.c index ae34a86a7..9edba4b3f 100644 --- a/MagickCore/nt-base.c +++ b/MagickCore/nt-base.c @@ -1405,19 +1405,22 @@ MagickPrivate int NTGhostscriptEXE(char *path,int length) if (ghost_semaphore == (SemaphoreInfo *) NULL) ActivateSemaphoreInfo(&ghost_semaphore); LockSemaphoreInfo(ghost_semaphore); - if (NTGhostscriptGetString("GS_DLL",&is_64_bit_version,program, - sizeof(program)) == FALSE) + if (*program == '\0') { - UnlockSemaphoreInfo(ghost_semaphore); - return(FALSE); - } - p=strrchr(program,'\\'); - if (p != (char *) NULL) - { - p++; - *p='\0'; - (void) ConcatenateMagickString(program,is_64_bit_version ? - "gswin64c.exe" : "gswin32c.exe",sizeof(program)); + if (NTGhostscriptGetString("GS_DLL",&is_64_bit_version,program, + sizeof(program)) == FALSE) + { + UnlockSemaphoreInfo(ghost_semaphore); + return(FALSE); + } + p=strrchr(program,'\\'); + if (p != (char *) NULL) + { + p++; + *p='\0'; + (void) ConcatenateMagickString(program,is_64_bit_version ? + "gswin64c.exe" : "gswin32c.exe",sizeof(program)); + } } UnlockSemaphoreInfo(ghost_semaphore); } diff --git a/MagickCore/prepress.c b/MagickCore/prepress.c index 50da1886b..4b618090b 100644 --- a/MagickCore/prepress.c +++ b/MagickCore/prepress.c @@ -141,7 +141,8 @@ MagickExport double GetImageTotalInkDensity(Image *image, #pragma omp critical (MagickCore_GetImageTotalInkDensity) #endif { - total_ink_density=density; + if (density > total_ink_density) + total_ink_density=density; } p+=GetPixelChannels(image); } diff --git a/MagickCore/quantize.c b/MagickCore/quantize.c index e37f04645..dcb8cc9f5 100644 --- a/MagickCore/quantize.c +++ b/MagickCore/quantize.c @@ -3384,14 +3384,17 @@ static MagickBooleanType SetGrayscaleImage(Image *image, #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_SetGrayscaleImage) #endif - colormap_index[intensity]=(ssize_t) image->colors; - image->colormap[image->colors].red=(double) - GetPixelRed(image,q); - image->colormap[image->colors].green=(double) - GetPixelGreen(image,q); - image->colormap[image->colors].blue=(double) - GetPixelBlue(image,q); - image->colors++; + if (colormap_index[intensity] < 0) + { + colormap_index[intensity]=(ssize_t) image->colors; + image->colormap[image->colors].red=(double) + GetPixelRed(image,q); + image->colormap[image->colors].green=(double) + GetPixelGreen(image,q); + image->colormap[image->colors].blue=(double) + GetPixelBlue(image,q); + image->colors++; + } } SetPixelIndex(image,(Quantum) colormap_index[intensity],q); q+=GetPixelChannels(image); diff --git a/MagickCore/xml-tree.c b/MagickCore/xml-tree.c index a23b7228b..e9b4a8a08 100644 --- a/MagickCore/xml-tree.c +++ b/MagickCore/xml-tree.c @@ -451,7 +451,8 @@ static char **DestroyXMLTreeAttributes(char **attributes) /* Destroy attribute tag and value. */ - attributes[i]=DestroyString(attributes[i]); + if (attributes[i] != (char *) NULL) + attributes[i]=DestroyString(attributes[i]); if (attributes[i+1] != (char *) NULL) attributes[i+1]=DestroyString(attributes[i+1]); } @@ -526,7 +527,8 @@ static void DestroyXMLTreeRoot(XMLTreeInfo *xml_info) attributes[0]=DestroyString(attributes[0]); for (j=1; attributes[j] != (char *) NULL; j+=3) { - attributes[j]=DestroyString(attributes[j]); + if (attributes[j] != (char *) NULL) + attributes[j]=DestroyString(attributes[j]); if (attributes[j+1] != (char *) NULL) attributes[j+1]=DestroyString(attributes[j+1]); if (attributes[j+2] != (char *) NULL) diff --git a/coders/dds.c b/coders/dds.c index 80f58320d..d7e55d5d2 100644 --- a/coders/dds.c +++ b/coders/dds.c @@ -1175,13 +1175,16 @@ static void CompressClusterFit(const size_t count, #pragma omp critical (DDS_CompressClusterFit) #endif { - VectorCopy43(a,start); - VectorCopy43(b,end); - bestError = error; - besti = i; - bestj = j; - bestk = k; - bestIteration = iterationIndex; + if (error < bestError) + { + VectorCopy43(a,start); + VectorCopy43(b,end); + bestError = error; + besti = i; + bestj = j; + bestk = k; + bestIteration = iterationIndex; + } } } -- 2.40.0