Program Options: string iterator not dereferencable

Hi, I think there's a bug in the program options library. It appears to dereference an invalid string iterator. libs\program_options\src\value_semantic.cpp: void validate(any& v, const vector<string>& xs, std::string*, int) { check_first_occurrence(v); string s(get_single_string(xs)); if (*s.begin() == '\'' && *s.rbegin() == '\'' || *s.begin() == '"' && *s.rbegin() == '"') v = any(s.substr(1, s.size()-2)); else v = any(s); } A !s.empty() check should be added.

Olaf van der Spek wrote:
Hi,
I think there's a bug in the program options library. It appears to dereference an invalid string iterator.
libs\program_options\src\value_semantic.cpp: void validate(any& v, const vector<string>& xs, std::string*, int) { check_first_occurrence(v); string s(get_single_string(xs)); if (*s.begin() == '\'' && *s.rbegin() == '\'' || *s.begin() == '"' && *s.rbegin() == '"') v = any(s.substr(1, s.size()-2)); else v = any(s); }
A !s.empty() check should be added.
Hi Olaf, the fix was just comitted, on trunk and on release branch. Thanks for the report! - Volodya
participants (2)
-
Olaf van der Spek
-
Vladimir Prus