Hello folks, The current code in RulerItem2::settingsChanged() is dereferencing the null pointer 'profWidget'. It can cause a segmentation fault.
All the best, Marcos
From 7b9c36e93951b9202790dc700ca1240e70173f01 Mon Sep 17 00:00:00 2001 From: Marcos Cardinot <[email protected]> Date: Tue, 17 Mar 2015 20:35:11 -0300 Subject: [PATCH] RulerItem2::settingsChanged() - NULL pointer dereference The current code is dereferencing the null pointer 'profWidget'. It can cause a segmentation fault. Signed-off-by: Marcos Cardinot <[email protected]> --- qt-ui/profile/ruleritem.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index ddd8f46..1c874be 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -81,9 +81,15 @@ RulerItem2::RulerItem2() : source(new RulerNodeItem2()), void RulerItem2::settingsChanged() { ProfileWidget2 *profWidget = NULL; - if (scene() && scene()->views().count()) + if (scene() && scene()->views().count()) { profWidget = qobject_cast<ProfileWidget2 *>(scene()->views().first()); - setVisible(profWidget->currentState == ProfileWidget2::PROFILE ? prefs.rulergraph : false); + } + + if (profWidget && profWidget->currentState == ProfileWidget2::PROFILE) { + setVisible(prefs.rulergraph); + } else { + setVisible(false); + } } void RulerItem2::recalculate() -- 1.7.9.5
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
