[Boost-bugs] [Boost C++ Libraries] #6955: Spirit parse_nan() may dereference end iterator

Subject: [Boost-bugs] [Boost C++ Libraries] #6955: Spirit parse_nan() may dereference end iterator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-31 00:22:08


#6955: Spirit parse_nan() may dereference end iterator
-----------------------------------------------+----------------------------
 Reporter: michael.douglas.schmidt@… | Owner: djowel
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: spirit
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: nan |
-----------------------------------------------+----------------------------
 The function `parse_nan(first, last)` will dereference the end iterator
 when parsing the string "nan", which may lead to undefined behavior.
 {{{
 File: boost/spirit/home/qi/numeric/real_policies.hpp
 Line: 119
 }}}

 This occurs for instance using the following parser:
 {{{
 std::string s = "nan";
 auto s_begin = s.begin();
 auto s_end = s.end();
 double out;
 qi::phrase_parse(s_begin, s_end, qi::double_, ascii::space, out);
 }}}

 The problem occurs in parse_nan():
 {{{
 117: if (detail::string_parse("nan", "NAN", first, last, unused))
 118: {
 119: if (*first == '(')
 }}}

 Line 119 should check if `first == last` first since
 `detail::string_parse()` may increment `first`.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6955>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC