]> granicus.if.org Git - imagemagick/commitdiff
Eliminate divide-by-zero in DDS coder
authorCristy <urban-warrior@imagemagick.org>
Tue, 23 Jan 2018 14:32:36 +0000 (09:32 -0500)
committerCristy <urban-warrior@imagemagick.org>
Tue, 23 Jan 2018 14:32:36 +0000 (09:32 -0500)
Credit OZZ Fuzz

coders/dds.c

index 85e33a59183168fa5d368953f31464e59fc1788c..b82e5f119b74a652d1b27d0caf9ae7906e24cdd4 100644 (file)
@@ -1427,7 +1427,7 @@ static void ComputePrincipleComponent(const float *covariance,
     w.z = (row2.z * v.z) + w.z;
     w.w = (row2.w * v.z) + w.w;
 
-    a = 1.0f / MagickMax(w.x,MagickMax(w.y,w.z));
+    a = (float) PerceptibleReciprocal(MagickMax(w.x,MagickMax(w.y,w.z)));
 
     v.x = w.x * a;
     v.y = w.y * a;
@@ -1827,6 +1827,7 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     status=SetImageExtent(image,image->columns,image->rows,exception);
     if (status == MagickFalse)
       return(DestroyImageList(image));
+    (void) SetImageBackgroundColor(image,exception);
     status=(decoder)(image_info,image,&dds_info,read_mipmaps,exception);
     if (status == MagickFalse)
       {