From a3a9d5665e1663b52d026dc475c84b97973aae8a Mon Sep 17 00:00:00 2001 From: jprochazk Date: Sun, 19 Jul 2020 09:35:49 +0200 Subject: [PATCH] add break to binary_reader::get_binary and get_string --- include/nlohmann/detail/input/binary_reader.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index a650b2d0..45fcfff4 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -2271,15 +2271,15 @@ class binary_reader string_t& result) { bool success = true; - std::generate_n(std::back_inserter(result), len, [this, &success, &format]() - { + for(NumberType i = 0; i < len; i++) { get(); if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string"))) { success = false; + break; } return std::char_traits::to_char_type(current); - }); + }; return success; } @@ -2303,15 +2303,15 @@ class binary_reader binary_t& result) { bool success = true; - std::generate_n(std::back_inserter(result), len, [this, &success, &format]() - { + for(NumberType i = 0; i < len; i++) { get(); if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary"))) { success = false; + break; } return static_cast(current); - }); + } return success; }