From af711143a02e4c12dfd47a1f5cdcfb3bb2e2ea7b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 13 Oct 2026 21:13:48 +0200 Subject: [PATCH] Use data() instead of c_str() in the multi-byte decimal point path Signed-off-by: Niels Lohmann --- include/nlohmann/detail/input/number_parse.hpp | 4 ++-- single_include/nlohmann/json.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/detail/input/number_parse.hpp b/include/nlohmann/detail/input/number_parse.hpp index 835e623d2..4668682e9 100644 --- a/include/nlohmann/detail/input/number_parse.hpp +++ b/include/nlohmann/detail/input/number_parse.hpp @@ -986,8 +986,8 @@ void convert_float_locale_aware(StringType& token, std::size_t decimal_point_pos { std::string buffer(token.data(), token.size()); buffer.replace(decimal_point_position, 1, decimal_point); - strtof_by_type(value, buffer.c_str(), &endptr); - complete = endptr == buffer.c_str() + buffer.size(); + strtof_by_type(value, buffer.data(), &endptr); + complete = endptr == buffer.data() + buffer.size(); } if (JSON_HEDLEY_LIKELY(complete)) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 7f83650f7..bead1e45e 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -10432,8 +10432,8 @@ void convert_float_locale_aware(StringType& token, std::size_t decimal_point_pos { std::string buffer(token.data(), token.size()); buffer.replace(decimal_point_position, 1, decimal_point); - strtof_by_type(value, buffer.c_str(), &endptr); - complete = endptr == buffer.c_str() + buffer.size(); + strtof_by_type(value, buffer.data(), &endptr); + complete = endptr == buffer.data() + buffer.size(); } if (JSON_HEDLEY_LIKELY(complete))