summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/planner.c2
-rw-r--r--desktop-widgets/preferences/preferences_defaults.cpp2
-rw-r--r--qt-models/tankinfomodel.cpp5
3 files changed, 4 insertions, 5 deletions
diff --git a/core/planner.c b/core/planner.c
index cb013799d..cc6874c3f 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -209,7 +209,7 @@ void fill_default_cylinder(cylinder_t *cyl)
if (!cyl_name)
return;
- while (ti->name != NULL) {
+ while (ti->name != NULL && ti < tank_info + MAX_TANK_INFO) {
if (strcmp(ti->name, cyl_name) == 0)
break;
ti++;
diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp
index 4500ecac2..e0a24530a 100644
--- a/desktop-widgets/preferences/preferences_defaults.cpp
+++ b/desktop-widgets/preferences/preferences_defaults.cpp
@@ -52,7 +52,7 @@ void PreferencesDefaults::refreshSettings()
ui->localDefaultFile->setChecked(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
ui->default_cylinder->clear();
- for (int i = 0; tank_info[i].name != NULL; i++) {
+ for (int i = 0; tank_info[i].name != NULL && i < MAX_TANK_INFO; i++) {
ui->default_cylinder->addItem(tank_info[i].name);
if (prefs.default_cylinder && strcmp(tank_info[i].name, prefs.default_cylinder) == 0)
ui->default_cylinder->setCurrentIndex(i);
diff --git a/qt-models/tankinfomodel.cpp b/qt-models/tankinfomodel.cpp
index 49e42830c..0a54cd305 100644
--- a/qt-models/tankinfomodel.cpp
+++ b/qt-models/tankinfomodel.cpp
@@ -91,7 +91,7 @@ TankInfoModel::TankInfoModel() : rows(-1)
{
setHeaderDataStrings(QStringList() << tr("Description") << tr("ml") << tr("bar"));
struct tank_info_t *info = tank_info;
- for (info = tank_info; info->name; info++, rows++) {
+ for (info = tank_info; info->name && info < tank_info + MAX_TANK_INFO; info++, rows++) {
QString infoName = gettextFromC::tr(info->name);
if (infoName.count() > biggerEntry.count())
biggerEntry = infoName;
@@ -111,8 +111,7 @@ void TankInfoModel::update()
rows = -1;
}
struct tank_info_t *info = tank_info;
- for (info = tank_info; info->name; info++, rows++)
- ;
+ for (info = tank_info; info->name && info < tank_info + MAX_TANK_INFO; info++, rows++);
if (rows > -1) {
beginInsertRows(QModelIndex(), 0, rows);