summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-18 14:35:31 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-18 14:37:08 -0800
commit733108b47385c68e163baebc10ff29c145d3685f (patch)
treefd076a257ba4804e2d6ad5f74b4a84a08eb6b9fc /qt-ui
parent2c6830c399d711db8149a2bc1bec0a83e54cae0c (diff)
downloadsubsurface-733108b47385c68e163baebc10ff29c145d3685f.tar.gz
Fix potential crash in getColor functions
If the index is out of range, just return black. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp4
-rw-r--r--qt-ui/graphicsview-common.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 7fa1a8783..4ff6894e6 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -45,7 +45,9 @@ QString dpGasToStr(const divedatapoint& p)
QColor getColor(const color_indice_t i)
{
- return profile_color[i].at(0);
+ if ( profile_color.count() > i && i >= 0)
+ return profile_color[i].at(0);
+ return QColor(Qt::black);
}
static DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
diff --git a/qt-ui/graphicsview-common.cpp b/qt-ui/graphicsview-common.cpp
index b4b3b6bce..5415cfe1f 100644
--- a/qt-ui/graphicsview-common.cpp
+++ b/qt-ui/graphicsview-common.cpp
@@ -58,5 +58,7 @@ void fill_profile_color()
QColor getColor(const color_indice_t i, bool isGrayscale = false)
{
- return profile_color[i].at((isGrayscale) ? 1 : 0);
+ if (profile_color.count() > i && i >= 0)
+ return profile_color[i].at((isGrayscale) ? 1 : 0);
+ return QColor(Qt::black);
}