aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira@fluxbox.org>2015-01-10 21:44:37 (GMT)
committerMathias Gumz <akira@fluxbox.org>2015-01-10 21:51:04 (GMT)
commit7b8fd2d81ad80a73564fc9fbb779f47568f12652 (patch)
tree7eb7ed8dfe7de48ac9d7bf598ef8f953ecf95277
parentd8c11d0852d889f4df23c9398463aa3848e0e7c7 (diff)
downloadfluxbox-7b8fd2d81ad80a73564fc9fbb779f47568f12652.zip
fluxbox-7b8fd2d81ad80a73564fc9fbb779f47568f12652.tar.bz2
Fix bug: integer underflow in startup phase
When fluxbox comes up some of it's drawables span a 1x1 area. Subtracting from such small numbers bigger ones always lead to massive problems when 'unsigned int' are involved: 'button_width' is an unsigned int of '1' (this might be caused by another issue or on purpose, anyway), subtracting -10 or any other number should result in something < 0 when in reality an integer underflow happen: max_width is now MAX_INT-something big. This makes fluxbox crash under certain circumstances. This fixes bug #1116.
-rw-r--r--src/FbTk/TextButton.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc
index 611580c..a177f25 100644
--- a/src/FbTk/TextButton.cc
+++ b/src/FbTk/TextButton.cc
@@ -143,11 +143,17 @@ void TextButton::drawText(int x_offset, int y_offset, FbDrawable *drawable) {
143 unsigned int textlen = visual.size(); 143 unsigned int textlen = visual.size();
144 unsigned int button_width = width(); 144 unsigned int button_width = width();
145 unsigned int button_height = height(); 145 unsigned int button_height = height();
146 const int max_width = static_cast<int>(button_width) - x_offset -
147 m_left_padding - m_right_padding;
148
149 if (max_width <= bevel()) {
150 return;
151 }
146 152
147 translateSize(m_orientation, button_width, button_height); 153 translateSize(m_orientation, button_width, button_height);
148 154
149 // horizontal alignment, cut off text if needed 155 // horizontal alignment, cut off text if needed
150 int align_x = FbTk::doAlignment(button_width - x_offset - m_left_padding - m_right_padding, 156 int align_x = FbTk::doAlignment(max_width,
151 bevel(), justify(), font(), 157 bevel(), justify(), font(),
152 visual.data(), visual.size(), 158 visual.data(), visual.size(),
153 textlen); // return new text len 159 textlen); // return new text len