[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [krita/rempt/impex-refactoring] plugins/tools/defaulttool/defaulttool: Fix potential crash in
From: Frederik Gladhorn <gladhorn () kde ! org>
Date: 2016-11-05 14:52:03
Message-ID: E1c32KB-0001CD-1f () code ! kde ! org
[Download RAW message or body]
Git commit dcb0fd179014c0f0d0231fbc4ef5e1684fdc8906 by Frederik Gladhorn.
Committed on 05/11/2016 at 14:22.
Pushed by gladhorn into branch 'rempt/impex-refactoring'.
Fix potential crash in ShapeResizeStrategy::ShapeResizeStrategy
There is a check for shape being a nullptr. Just below it is code that
accesses shape. Either the nullptr check is not needed or the code below would
dereference it. Play it safe.
M +28 -28 plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp
http://commits.kde.org/krita/dcb0fd179014c0f0d0231fbc4ef5e1684fdc8906
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp \
b/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp index \
cb47101..eb11570 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp
+++ b/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp
@@ -65,35 +65,35 @@ ShapeResizeStrategy::ShapeResizeStrategy(KoToolBase *tool, const \
QPointF &clicke m_unwindMatrix = m_windMatrix.inverted();
m_initialSize = shape->size();
m_initialPosition = m_windMatrix.map(QPointF());
- }
- switch (direction) {
- case KoFlake::TopMiddleHandle:
- m_start = 0.5 * (shape->absolutePosition(KoFlake::TopLeftCorner) + \
shape->absolutePosition(KoFlake::TopRightCorner));
- m_top = true; m_bottom = false; m_left = false; m_right = false; break;
- case KoFlake::TopRightHandle:
- m_start = shape->absolutePosition(KoFlake::TopRightCorner);
- m_top = true; m_bottom = false; m_left = false; m_right = true; break;
- case KoFlake::RightMiddleHandle:
- m_start = 0.5 * (shape->absolutePosition(KoFlake::TopRightCorner) + \
shape->absolutePosition(KoFlake::BottomRightCorner));
- m_top = false; m_bottom = false; m_left = false; m_right = true; break;
- case KoFlake::BottomRightHandle:
- m_start = shape->absolutePosition(KoFlake::BottomRightCorner);
- m_top = false; m_bottom = true; m_left = false; m_right = true; break;
- case KoFlake::BottomMiddleHandle:
- m_start = 0.5 * (shape->absolutePosition(KoFlake::BottomRightCorner) + \
shape->absolutePosition(KoFlake::BottomLeftCorner));
- m_top = false; m_bottom = true; m_left = false; m_right = false; break;
- case KoFlake::BottomLeftHandle:
- m_start = shape->absolutePosition(KoFlake::BottomLeftCorner);
- m_top = false; m_bottom = true; m_left = true; m_right = false; break;
- case KoFlake::LeftMiddleHandle:
- m_start = 0.5 * (shape->absolutePosition(KoFlake::BottomLeftCorner) + \
shape->absolutePosition(KoFlake::TopLeftCorner));
- m_top = false; m_bottom = false; m_left = true; m_right = false; break;
- case KoFlake::TopLeftHandle:
- m_start = shape->absolutePosition(KoFlake::TopLeftCorner);
- m_top = true; m_bottom = false; m_left = true; m_right = false; break;
- default:
- Q_ASSERT(0); // illegal 'corner'
+ switch (direction) {
+ case KoFlake::TopMiddleHandle:
+ m_start = 0.5 * (shape->absolutePosition(KoFlake::TopLeftCorner) + \
shape->absolutePosition(KoFlake::TopRightCorner)); + m_top = true; \
m_bottom = false; m_left = false; m_right = false; break; + case \
KoFlake::TopRightHandle: + m_start = \
shape->absolutePosition(KoFlake::TopRightCorner); + m_top = true; m_bottom \
= false; m_left = false; m_right = true; break; + case \
KoFlake::RightMiddleHandle: + m_start = 0.5 * \
(shape->absolutePosition(KoFlake::TopRightCorner) + \
shape->absolutePosition(KoFlake::BottomRightCorner)); + m_top = false; \
m_bottom = false; m_left = false; m_right = true; break; + case \
KoFlake::BottomRightHandle: + m_start = \
shape->absolutePosition(KoFlake::BottomRightCorner); + m_top = false; \
m_bottom = true; m_left = false; m_right = true; break; + case \
KoFlake::BottomMiddleHandle: + m_start = 0.5 * \
(shape->absolutePosition(KoFlake::BottomRightCorner) + \
shape->absolutePosition(KoFlake::BottomLeftCorner)); + m_top = false; \
m_bottom = true; m_left = false; m_right = false; break; + case \
KoFlake::BottomLeftHandle: + m_start = \
shape->absolutePosition(KoFlake::BottomLeftCorner); + m_top = false; \
m_bottom = true; m_left = true; m_right = false; break; + case \
KoFlake::LeftMiddleHandle: + m_start = 0.5 * \
(shape->absolutePosition(KoFlake::BottomLeftCorner) + \
shape->absolutePosition(KoFlake::TopLeftCorner)); + m_top = false; \
m_bottom = false; m_left = true; m_right = false; break; + case \
KoFlake::TopLeftHandle: + m_start = \
shape->absolutePosition(KoFlake::TopLeftCorner); + m_top = true; m_bottom \
= false; m_left = true; m_right = false; break; + default:
+ Q_ASSERT(0); // illegal 'corner'
+ }
}
tool->setStatusText(i18n("Press CTRL to resize from center."));
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic