aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/divelogimportdialog.cpp
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-01-23 20:06:31 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-24 07:09:22 +1200
commitd501445bea38f1fa81c57160cef675afd9fd38dc (patch)
treecf63c131b3a6bf2af767c809dfc578266da6dc3b /qt-ui/divelogimportdialog.cpp
parent9c4a4cb9f8e2bf1678e5f70126bcfe1e524bc478 (diff)
downloadsubsurface-d501445bea38f1fa81c57160cef675afd9fd38dc.tar.gz
Fix segm fault on known CSV imports
If the header line is not set up properly, the known imports assignments will index out of the array. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelogimportdialog.cpp')
-rw-r--r--qt-ui/divelogimportdialog.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index a2b2cc3a2..64bb76418 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -435,23 +435,23 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
// now set up time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
for (int i = 0; i < currColumns.count(); i++)
headers.append("");
- if (CSVApps[value].time != -1)
+ if (CSVApps[value].time != -1 && CSVApps[value].time < currColumns.count())
headers.replace(CSVApps[value].time, tr("Sample time"));
- if (CSVApps[value].depth != -1)
+ if (CSVApps[value].depth != -1 && CSVApps[value].depth < currColumns.count())
headers.replace(CSVApps[value].depth, tr("Sample depth"));
- if (CSVApps[value].temperature != -1)
+ if (CSVApps[value].temperature != -1 && CSVApps[value].temperature < currColumns.count())
headers.replace(CSVApps[value].temperature, tr("Sample temperature"));
- if (CSVApps[value].po2 != -1)
+ if (CSVApps[value].po2 != -1 && CSVApps[value].po2 < currColumns.count())
headers.replace(CSVApps[value].po2, tr("Sample po2"));
- if (CSVApps[value].cns != -1)
+ if (CSVApps[value].cns != -1 && CSVApps[value].cns < currColumns.count())
headers.replace(CSVApps[value].cns, tr("Sample cns"));
- if (CSVApps[value].ndl != -1)
+ if (CSVApps[value].ndl != -1 && CSVApps[value].ndl < currColumns.count())
headers.replace(CSVApps[value].ndl, tr("Sample ndl"));
- if (CSVApps[value].tts != -1)
+ if (CSVApps[value].tts != -1 && CSVApps[value].tts < currColumns.count())
headers.replace(CSVApps[value].tts, tr("Sample tts"));
- if (CSVApps[value].stopdepth != -1)
+ if (CSVApps[value].stopdepth != -1 && CSVApps[value].stopdepth < currColumns.count())
headers.replace(CSVApps[value].stopdepth, tr("Sample stopdepth"));
- if (CSVApps[value].pressure != -1)
+ if (CSVApps[value].pressure != -1 && CSVApps[value].pressure < currColumns.count())
headers.replace(CSVApps[value].pressure, tr("Samples pressure"));
}