diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2013-02-06 00:45:38 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2013-02-06 00:45:38 (GMT) |
commit | 779618e45d4571bb6a4866aa2e398780f4b4da5d (patch) | |
tree | f761f05065eed019220ba823e95eda67c8cd41c6 /src/FbTk | |
parent | 3e4ee48bf16be6925b7c35ab8bd73bd962c674d8 (diff) | |
download | fluxbox_pavel-779618e45d4571bb6a4866aa2e398780f4b4da5d.zip fluxbox_pavel-779618e45d4571bb6a4866aa2e398780f4b4da5d.tar.bz2 |
Fix integer overflow for bigger textures
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/TextureRender.cc | 8 |
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 | ||
114 | template <typename T> int sign(T val) { | ||
115 | return (T(0) < val) - (val < T(0)); | ||
116 | } | ||
117 | |||
114 | std::vector<char>& getGradientBuffer(size_t size) { | 118 | std::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]; |