diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 2e5c140..fb76d29 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1062,9 +1062,10 @@ namespace boost { ) return false; #endif - if(*begin == decimal_point){ + if(*begin == decimal_point) { ++ begin; found_decimal = true; + if (!found_number_before_exp && begin==end) return false; continue; }else { if (!found_number_before_exp) return false; diff --git a/test/lexical_cast_float_types_test.cpp b/test/lexical_cast_float_types_test.cpp index 808f456..60db0e1 100755 --- a/test/lexical_cast_float_types_test.cpp +++ b/test/lexical_cast_float_types_test.cpp @@ -261,6 +261,7 @@ void test_converion_to_float_types() BOOST_CHECK_THROW(lexical_cast(".e"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(".11111111111111111111111111111111111111111111111111111111111111111111ee"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(".11111111111111111111111111111111111111111111111111111111111111111111e-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("."), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("-B"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("0xB"), bad_lexical_cast); @@ -276,6 +277,7 @@ void test_converion_to_float_types() BOOST_CHECK_THROW(lexical_cast("-"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast('\0'), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast('-'), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast('.'), bad_lexical_cast); } template