File commit_1f8b1b034ccf1713a5d123a4c327290f86d17d53.diff of Package kdelibs4.1362

commit 1f8b1b034ccf1713a5d123a4c327290f86d17d53
Author: Maks Orlovich <maksim@kde.org>
Date:   Mon Feb 6 07:11:08 2012 -0500

    Fix sign extension causing image scaling to read from wrong locations
    with very high ratios.

diff --git a/khtml/imload/scaledimageplane.h b/khtml/imload/scaledimageplane.h
index 953c34c..35fec21 100644
--- a/khtml/imload/scaledimageplane.h
+++ b/khtml/imload/scaledimageplane.h
@@ -24,6 +24,8 @@
 #ifndef SCALED_IMAGE_PLANE_H
 #define SCALED_IMAGE_PLANE_H
 
+#include <cassert>
+
 #include "array2d.h"
 #include "imageplane.h"
 #include "rawimageplane.h"
@@ -48,21 +50,25 @@ private:
 
         //### I bet this has all sorts of imprecision problems w/high ratios
         unsigned int* origin = new unsigned int[scaled];
-        
+
         //### FIXME: replace with something that clamps on right edge later?
         double ratio    = double(orig)/double(scaled);
-        int    intRatio = int(ratio*65536.0 + 1);
-        int    pos      = 0;
-        
+
+        // Should be assured by ImageManager::isAcceptableScaleSize
+        assert(ratio < 65536);
+
+        unsigned intRatio = unsigned(ratio*65536.0 + 1);
+        unsigned pos      = 0;
+
         for (unsigned int pix = 0; pix < scaled; pix++)
         {
             origin[pix]  =  pos >> 16;
             pos          += intRatio;
         }
-        
+
         return origin;
     }
-    
+
     unsigned int* xScaleTable;
     unsigned int* yScaleTable;
 public:
openSUSE Build Service is sponsored by