Skip to content

Commit a84f60a

Browse files
committed
More checking
1 parent 74dbb9a commit a84f60a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ static int fc_int(const std::string& s) {
9797
return val;
9898
}
9999
static double fc_double(const std::string& s) {
100-
return std::stod(s);
100+
size_t pos;
101+
double val = std::stod(s, &pos);
102+
if (pos != s.size()) throw std::invalid_argument("trailing characters in double: " + s);
103+
return val;
101104
}
102105
static const std::string& fc_string(const std::string& s) { return s; }
103106

0 commit comments

Comments
 (0)