From 71227ffc0483b883b96baef9ef4eac63abda8991 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 15 Nov 2018 10:21:08 +0400 Subject: [PATCH] Handle possible invalid iterator issue during settings parsing --- components/config/gamesettings.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index 29dbe0391..b20805a11 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -338,6 +338,9 @@ bool Config::GameSettings::writeFileWithComments(QFile &file) if (!comments.empty() && index != -1 && settingRegex.captureCount() >= 2 && mUserSettings.find(settingRegex.cap(1)) != mUserSettings.end()) { + if (commentStart == fileCopy.end()) + throw std::runtime_error("Config::GameSettings: failed to parse settings - iterator is past of end of settings file"); + for (std::vector::const_iterator it = comments.begin(); it != comments.end(); ++it) { *commentStart = *it;