From da85b3a4ee3125acd2e8a09012561d84cd246cd1 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 1 Aug 2015 13:25:35 +1000 Subject: [PATCH] Update to keeping config comments (Feature #2535) -An attempt to fix Coverity-Scan warning (see: https://github.com/OpenMW/openmw/pull/618#discussion_r33641670) - Unable to test until a PR can be submitted. --- components/config/gamesettings.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index ca6bfd80da..10b0234d1c 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;