mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-17 10:21:11 +00:00
Merge pull request #2039 from akortunov/coverity
Handle last Coverity Scan issues left
This commit is contained in:
commit
519a6b3682
@ -7,6 +7,8 @@
|
|||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <components/debug/debuglog.hpp>
|
||||||
|
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
@ -210,18 +212,28 @@ void CSVWorld::ScriptSubView::useHint (const std::string& hint)
|
|||||||
unsigned line = 0, column = 0;
|
unsigned line = 0, column = 0;
|
||||||
char c;
|
char c;
|
||||||
std::istringstream stream (hint.c_str()+1);
|
std::istringstream stream (hint.c_str()+1);
|
||||||
switch(hint[0]){
|
switch(hint[0])
|
||||||
|
{
|
||||||
case 'R':
|
case 'R':
|
||||||
case 'r':
|
case 'r':
|
||||||
{
|
{
|
||||||
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
||||||
QString source = mModel->data (index).toString();
|
QString source = mModel->data (index).toString();
|
||||||
|
unsigned stringSize = source.length();
|
||||||
unsigned pos, dummy;
|
unsigned pos, dummy;
|
||||||
if (!(stream >> c >> dummy >> pos) )
|
if (!(stream >> c >> dummy >> pos) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (unsigned i = 0; i <= pos; ++i){
|
if (pos > stringSize)
|
||||||
if (source[i] == '\n'){
|
{
|
||||||
|
Log(Debug::Warning) << "CSVWorld::ScriptSubView: requested position is higher than actual string length";
|
||||||
|
pos = stringSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned i = 0; i <= pos; ++i)
|
||||||
|
{
|
||||||
|
if (source[i] == '\n')
|
||||||
|
{
|
||||||
++line;
|
++line;
|
||||||
column = i+1;
|
column = i+1;
|
||||||
}
|
}
|
||||||
@ -231,7 +243,7 @@ void CSVWorld::ScriptSubView::useHint (const std::string& hint)
|
|||||||
}
|
}
|
||||||
case 'l':
|
case 'l':
|
||||||
if (!(stream >> c >> line >> column))
|
if (!(stream >> c >> line >> column))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCursor cursor = mEditor->textCursor();
|
QTextCursor cursor = mEditor->textCursor();
|
||||||
|
@ -338,6 +338,9 @@ bool Config::GameSettings::writeFileWithComments(QFile &file)
|
|||||||
if (!comments.empty() && index != -1 && settingRegex.captureCount() >= 2 &&
|
if (!comments.empty() && index != -1 && settingRegex.captureCount() >= 2 &&
|
||||||
mUserSettings.find(settingRegex.cap(1)) != mUserSettings.end())
|
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<QString>::const_iterator it = comments.begin(); it != comments.end(); ++it)
|
for (std::vector<QString>::const_iterator it = comments.begin(); it != comments.end(); ++it)
|
||||||
{
|
{
|
||||||
*commentStart = *it;
|
*commentStart = *it;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user