[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdelibs/KDE/4.7] khtml/imload: Fix sign extension causing image scaling to read from wrong location
From: Maks Orlovich <maksim () kde ! org>
Date: 2012-02-08 13:16:44
Message-ID: 20120208131644.EEA8EA60B9 () git ! kde ! org
[Download RAW message or body]
Git commit 6f5f6ccf12ceabc0c1fc8a780bf9a87b8b344ff5 by Maks Orlovich.
Committed on 06/02/2012 at 13:11.
Pushed by orlovich into branch 'KDE/4.7'.
Fix sign extension causing image scaling to read from wrong locations
with very high ratios.
M +12 -6 khtml/imload/scaledimageplane.h
http://commits.kde.org/kdelibs/6f5f6ccf12ceabc0c1fc8a780bf9a87b8b344ff5
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:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic