From 3efd9534fb4b5a7edfdf2e810b0dca9ad89214a7 Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 12 May 2024 22:33:39 +0200 Subject: [PATCH] feat: fail to parse info strings on empty keys --- src/ObjCommon/InfoString/InfoString.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ObjCommon/InfoString/InfoString.cpp b/src/ObjCommon/InfoString/InfoString.cpp index 2f39d60a..14efada8 100644 --- a/src/ObjCommon/InfoString/InfoString.cpp +++ b/src/ObjCommon/InfoString/InfoString.cpp @@ -185,6 +185,16 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream) std::string key; while (infoStream.NextField(key)) { + if (key.empty()) + { + if (m_keys_by_insertion.empty()) + std::cerr << "Invalid info string: Got empty key at the start of the info string\n"; + else + std::cerr << "Invalid info string: Got empty key after key \"" << m_keys_by_insertion[m_keys_by_insertion.size() - 1] << "\"\n"; + + return false; + } + std::string value; if (!infoStream.NextField(value)) {