From f4a38b579f6ad66d4587ac278e906b4ed27050f2 Mon Sep 17 00:00:00 2001 From: Shunichi Nozawa Date: Mon, 19 Jun 2017 14:14:49 +0900 Subject: [PATCH] [rtc/AutoBalancer/GaitGenerator] Fix invalid access for step_count_list (https://github.com/fkanehiro/hrpsys-base/issues/1154) --- rtc/AutoBalancer/GaitGenerator.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rtc/AutoBalancer/GaitGenerator.cpp b/rtc/AutoBalancer/GaitGenerator.cpp index 54e4220d957..8df36caea57 100644 --- a/rtc/AutoBalancer/GaitGenerator.cpp +++ b/rtc/AutoBalancer/GaitGenerator.cpp @@ -210,8 +210,13 @@ namespace rats refzmp_count--; } else { refzmp_index++; - refzmp_count = one_step_count = step_count_list[refzmp_index]; - thp.set_one_step_count(one_step_count); + // Check length of step_count_list and refzmp_index + // The case if !(refzmp_index <= step_count_list.size()-1) is finalizing of gait_generator. + // If finalizing, this can be neglected. + if (refzmp_index <= step_count_list.size()-1) { + refzmp_count = one_step_count = step_count_list[refzmp_index]; + thp.set_one_step_count(one_step_count); + } //std::cerr << "fs " << fs_index << "/" << fnl.size() << " rf " << refzmp_index << "/" << refzmp_cur_list.size() << " flg " << std::endl; } };