From f9ad71f682776315c0d23d7f2eb73705b0e30534 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 10 Apr 2018 13:29:00 -0500 Subject: [PATCH] Fix fencepost error in autolabor/autohauler/labormanager. https://github.com/DFHack/dfhack/pull/1253#pullrequestreview-110903215 --- plugins/autohauler.cpp | 2 +- plugins/autolabor.cpp | 2 +- plugins/labormanager/labormanager.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/autohauler.cpp b/plugins/autohauler.cpp index e222a9702..c43ec110e 100644 --- a/plugins/autohauler.cpp +++ b/plugins/autohauler.cpp @@ -624,7 +624,7 @@ static void init_state() df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autohauler/labors/")).c_str()); // Ensure that the labor is defined in the existing list - if (labor >= 0 && size_t(labor) <= labor_infos.size()) + if (labor >= 0 && size_t(labor) < labor_infos.size()) { // Link the labor treatment with the associated persistent data item labor_infos[labor].set_config(*p); diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index 6ca0a2658..936ce4022 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -606,7 +606,7 @@ static void init_state() { string key = p->key(); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autolabor/labors/")).c_str()); - if (labor >= 0 && size_t(labor) <= labor_infos.size()) + if (labor >= 0 && size_t(labor) < labor_infos.size()) { labor_infos[labor].config = *p; labor_infos[labor].is_exclusive = default_labor_infos[labor].is_exclusive; diff --git a/plugins/labormanager/labormanager.cpp b/plugins/labormanager/labormanager.cpp index cf183f452..7c749edce 100644 --- a/plugins/labormanager/labormanager.cpp +++ b/plugins/labormanager/labormanager.cpp @@ -614,7 +614,7 @@ static void init_state() { string key = p->key(); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("labormanager/2.0/labors/")).c_str()); - if (labor >= 0 && size_t(labor) <= labor_infos.size()) + if (labor >= 0 && size_t(labor) < labor_infos.size()) { labor_infos[labor].config = *p; labor_infos[labor].active_dwarfs = 0;