diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index ca6bfd80d..10b0234d1 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -291,7 +291,8 @@ bool Config::GameSettings::writeFileWithComments(QFile &file) if (!comments.empty() && index != -1 && settingRegex.captureCount() >= 2 && mUserSettings.find(settingRegex.cap(1)) != mUserSettings.end()) { - for (std::vector::const_iterator it = comments.begin(); it != comments.end(); ++it) + for (std::vector::const_iterator it = comments.begin(); + it != comments.end() && commentStart != fileCopy.end(); ++it) { *commentStart = *it; ++commentStart;