From e3639d2bbcc0fbab50260ebc9c7f73e32bc910b9 Mon Sep 17 00:00:00 2001 From: Chris White Date: Sat, 14 Jan 2023 18:09:05 -0500 Subject: [PATCH] fix: parse_literal_string() properly issues invalid-utf8 errors When creating the inner iterator, make sure it points into the same vector as the outer iterator. Otherwise, attempts to reset the iterator wind up causing it to read out-of-bounds. Fixes #199. --- toml/parser.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toml/parser.hpp b/toml/parser.hpp index 590cb2a..8da4618 100644 --- a/toml/parser.hpp +++ b/toml/parser.hpp @@ -664,7 +664,8 @@ parse_literal_string(location& loc) const auto first = loc.iter(); if(const auto token = lex_literal_string::invoke(loc)) { - location inner_loc(loc.name(), token.unwrap().str()); + auto inner_loc = loc; + inner_loc.reset(first); const auto open = lex_apostrophe::invoke(inner_loc); if(!open)