summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Simeon <exxus@users.noreply.github.com>2018-10-25 23:05:18 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-25 23:23:03 +0100
commit8cf8d490d6b81c2b8ca6eb4a4852ffb2606b12c2 (patch)
treedd314ea7fcc6cb90ea334ee85fa74ee484dc8b39 /desktop-widgets
parentbb4c2031ef662b632eebb41b7173d8fd8324f1c6 (diff)
downloadsubsurface-8cf8d490d6b81c2b8ca6eb4a4852ffb2606b12c2.tar.gz
Fix bug in for loop that can lead to segfault
In case of big log files, where MAX_TANK_INFO is reached, tank_info[i] != NULL should be checked after i<MAX_TANK_INFO Signed-off-by: Simeon Geiger <simeon.geiger@gmail.com>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/preferences/preferences_defaults.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp
index 4d8c2a7e1..7ea704b96 100644
--- a/desktop-widgets/preferences/preferences_defaults.cpp
+++ b/desktop-widgets/preferences/preferences_defaults.cpp
@@ -84,7 +84,7 @@ void PreferencesDefaults::refreshSettings()
ui->localDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE);
ui->default_cylinder->clear();
- for (int i = 0; tank_info[i].name != NULL && i < MAX_TANK_INFO; i++) {
+ for (int i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) {
ui->default_cylinder->addItem(tank_info[i].name);
if (qPrefGeneral::default_cylinder() == tank_info[i].name)
ui->default_cylinder->setCurrentIndex(i);