diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-06 11:31:57 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-06 11:31:57 +0100 |
commit | 6105080a1ee8adec47f4dd0a8365ff9125b8c2ee (patch) | |
tree | 11110a61866f9f41183d42f3829f11ffbac42c14 /src/libserver/css | |
parent | 02f640128d28371846fb845aa15434a6cc49a87a (diff) | |
download | rspamd-6105080a1ee8adec47f4dd0a8365ff9125b8c2ee.tar.gz rspamd-6105080a1ee8adec47f4dd0a8365ff9125b8c2ee.zip |
[Minor] Css: Use old good strtod that does not throw exceptions
Diffstat (limited to 'src/libserver/css')
-rw-r--r-- | src/libserver/css/css_tokeniser.cxx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libserver/css/css_tokeniser.cxx b/src/libserver/css/css_tokeniser.cxx index 0374193bf..f4180b761 100644 --- a/src/libserver/css/css_tokeniser.cxx +++ b/src/libserver/css/css_tokeniser.cxx @@ -364,8 +364,13 @@ auto css_tokeniser::consume_number() -> struct css_parser_token /* I wish it was supported properly */ //auto conv_res = std::from_chars(&input[offset], &input[i], num); - std::string numbuf{&input[offset], (i - offset)}; - num = std::stod(numbuf); + char numbuf[128], *endptr = NULL; + rspamd_strlcpy(numbuf, &input[offset], MIN(i - offset + 1, sizeof(numbuf))); + num = g_ascii_strtod(numbuf, &endptr); + + if (endptr && *endptr != '\0') { + msg_debug_css("invalid number: %s", numbuf); + } offset = i; auto ret = make_token<css_parser_token::token_type::number_token>(num); |