aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2013-02-06 00:45:38 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2013-02-06 00:45:38 (GMT)
commit779618e45d4571bb6a4866aa2e398780f4b4da5d (patch)
treef761f05065eed019220ba823e95eda67c8cd41c6
parent3e4ee48bf16be6925b7c35ab8bd73bd962c674d8 (diff)
downloadfluxbox_pavel-779618e45d4571bb6a4866aa2e398780f4b4da5d.zip
fluxbox_pavel-779618e45d4571bb6a4866aa2e398780f4b4da5d.tar.bz2
Fix integer overflow for bigger textures
-rw-r--r--src/FbTk/TextureRender.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc
index 8c7087f..4623417 100644
--- a/src/FbTk/TextureRender.cc
+++ b/src/FbTk/TextureRender.cc
@@ -111,6 +111,10 @@ struct Vec2 {
111 } 111 }
112}; 112};
113 113
114template <typename T> int sign(T val) {
115 return (T(0) < val) - (val < T(0));
116}
117
114std::vector<char>& getGradientBuffer(size_t size) { 118std::vector<char>& getGradientBuffer(size_t size) {
115 static std::vector<char> buffer; 119 static std::vector<char> buffer;
116 if (buffer.size() < size) 120 if (buffer.size() < size)
@@ -469,10 +473,10 @@ void renderRectangleGradient(bool interlaced,
469 473
470 // check, if the point (x, y) is left or right of the vectors 474 // check, if the point (x, y) is left or right of the vectors
471 // 'a' and 'b'. if the point is on the same side for both 'a' and 475 // 'a' and 'b'. if the point is on the same side for both 'a' and
472 // 'b' (a.cross() is equal to b.cross()) then use the y_gradient, 476 // 'b' (a.cross() is equal to b.cross()) then use the x_gradient,
473 // otherwise use y_gradient 477 // otherwise use y_gradient
474 478
475 if ((a.cross(x, y) * b.cross(x, b.y + y)) < 0) { 479 if (sign(a.cross(x, y)) * sign(b.cross(x, b.y + y)) < 0) {
476 rgba[i] = x_gradient[x]; 480 rgba[i] = x_gradient[x];
477 } else { 481 } else {
478 rgba[i] = y_gradient[y]; 482 rgba[i] = y_gradient[y];