FIX: CLI: fix the size related issue in set_with_restore_2

jira: no-jira
Change-Id: I5b9b5dd3ae2eac63e9f494fd7b7ab5d4d38dbac7
(cherry picked from commit 030ebd1a3515a7d3dbdf3c6cfb77ff0b6b764f2e)
This commit is contained in:
lane.wei 2025-08-18 09:38:09 +08:00 committed by Noisyfox
parent 8e9281d68e
commit 41bfd5b8c2

View file

@ -514,11 +514,17 @@ public:
//backup original ones
std::vector<T> backup_values = this->values;
if (this->values.size() < (start+len))
if (this->values.size() < start) {
throw ConfigurationError("ConfigOptionVector::set_with_restore_2(): invalid size found");
}
else {
if (this->values.size() < start + len)
len = this->values.size() - start;
//erase the original ones
this->values.erase(this->values.begin() + start, this->values.begin() + start + len);
//erase the original ones
if (len > 0)
this->values.erase(this->values.begin() + start, this->values.begin() + start + len);
}
// Assign the new value from the rhs vector.
auto other = static_cast<const ConfigOptionVector<T>*>(rhs);