From a8a27b307f5cf516f967ea1e5321587ad6df0b7e Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Sat, 13 Oct 2018 14:47:28 +0100 Subject: [PATCH] Don't copy nul-terminators if any. --- include/incredis/int_conv.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/incredis/int_conv.hpp b/include/incredis/int_conv.hpp index 57fc3b6..6d284c6 100644 --- a/include/incredis/int_conv.hpp +++ b/include/incredis/int_conv.hpp @@ -66,13 +66,15 @@ namespace redis { template struct IntConv, std::string>> { static T conv (const std::string& in) { - return dhandy::ary_to_int(in.data(), in.data() + in.size()); + const auto size = in.size() - (in.empty() or in.back() ? 0 : 1); + return dhandy::ary_to_int(in.data(), in.data() + size); } }; template struct IntConv, boost::string_view>> { static T conv (const boost::string_view& in) { - return dhandy::ary_to_int(in.data(), in.data() + in.size()); + const auto size = in.size() - (in.empty() or in.back() ? 0 : 1); + return dhandy::ary_to_int(in.data(), in.data() + size); } }; } //namespace implem