From 9b8db6a2258ffd3f4f120c85d0fe32a7cfbfbe6a Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 15 Mar 2019 19:30:36 +0900 Subject: [PATCH] fix: remove extraneous null character after float the bug was introduced by snprintf --- toml/serializer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toml/serializer.hpp b/toml/serializer.hpp index c25f8b2..68bdbcc 100644 --- a/toml/serializer.hpp +++ b/toml/serializer.hpp @@ -36,7 +36,7 @@ struct serializer std::vector buf(bsz + 1, '\0'); // +1 for null character(\0) std::snprintf(buf.data(), buf.size(), fmt, this->float_prec_, f); - std::string token(buf.begin(), buf.end()); + std::string token(buf.begin(), std::prev(buf.end())); if(token.back() == '.') // 1. => 1.0 { token += '0';