From 1ead14589e1ba07ca6bf82743c936091840165f1 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 4 Nov 2020 23:24:02 +0900 Subject: [PATCH] fix: check if it is empty before calling back() --- toml/region.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toml/region.hpp b/toml/region.hpp index 6761aed..37ba3a3 100644 --- a/toml/region.hpp +++ b/toml/region.hpp @@ -344,7 +344,7 @@ struct region final : public region_base { // unwrap the first '#' by std::next. auto str = make_string(std::next(comment_found), iter); - if(str.back() == '\r') {str.pop_back();} + if(!str.empty() && str.back() == '\r') {str.pop_back();} com.push_back(std::move(str)); } else @@ -397,7 +397,7 @@ struct region final : public region_base { // unwrap the first '#' by std::next. auto str = make_string(std::next(comment_found), this->line_end()); - if(str.back() == '\r') {str.pop_back();} + if(!str.empty() && str.back() == '\r') {str.pop_back();} com.push_back(std::move(str)); } }