mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix potential crash in getColor functions
If the index is out of range, just return black. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2c6830c399
commit
733108b473
2 changed files with 6 additions and 2 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue