summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2017-11-20 15:17:16 +0100
committerDavid Tardon <dtardon@redhat.com>2017-11-20 15:18:01 +0100
commit8c57c864ef93556e11133350d42f8441151d25e2 (patch)
treedc492ee3c75525d374e7c1586294692e5a781181
parent5116e01cbfd183c5e3b75303461b57b5a3acdc78 (diff)
ofz#2370 avoid signed integer overflow
Change-Id: I77bbaf6ad9be5f80c530dd000c110b51c2527b28
-rw-r--r--src/lib/ABWStylesCollector.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/ABWStylesCollector.cpp b/src/lib/ABWStylesCollector.cpp
index efcd798..20848f7 100644
--- a/src/lib/ABWStylesCollector.cpp
+++ b/src/lib/ABWStylesCollector.cpp
@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <limits>
#include <vector>
#include <boost/algorithm/string.hpp>
@@ -182,7 +183,12 @@ void libabw::ABWStylesCollector::openCell(const char *props)
{
int leftAttach(0);
int rightAttach(0);
- if (findInt(_findCellProperty("left-attach"), leftAttach) && findInt(_findCellProperty("right-attach"), rightAttach))
+ if (findInt(_findCellProperty("left-attach"), leftAttach)
+ && findInt(_findCellProperty("right-attach"), rightAttach)
+ && leftAttach >= 0
+ && rightAttach > leftAttach
+ && rightAttach - leftAttach < std::numeric_limits<int>::max() - m_ps->m_tableStates.top().m_currentTableWidth
+ )
m_ps->m_tableStates.top().m_currentTableWidth += rightAttach - leftAttach;
else
m_ps->m_tableStates.top().m_currentTableWidth++;