1
0
Fork 0

Codefix: std::move string leaves the old one in an undefined state

pull/13789/head
Rubidium 2025-03-08 16:56:29 +01:00 committed by rubidium42
parent 7c97460080
commit afe66c7df4
2 changed files with 4 additions and 0 deletions

View File

@ -226,11 +226,13 @@ void IniLoadFile::LoadFromDisk(const std::string &filename, Subdirectory subdir)
s++; // skip [
group = &this->CreateGroup(std::string_view(s, e - s));
group->comment = std::move(comment);
comment.clear(); // std::move leaves comment in a "valid but unspecified state" according to the specification.
} else if (group != nullptr) {
if (group->type == IGT_SEQUENCE) {
/* A sequence group, use the line as item name without further interpretation. */
IniItem &item = group->CreateItem(std::string_view(buffer, e - buffer));
item.comment = std::move(comment);
comment.clear(); // std::move leaves comment in a "valid but unspecified state" according to the specification.
continue;
}
char *t;
@ -246,6 +248,7 @@ void IniLoadFile::LoadFromDisk(const std::string &filename, Subdirectory subdir)
/* it's an item in an existing group */
IniItem &item = group->CreateItem(std::string_view(s, t - s));
item.comment = std::move(comment);
comment.clear(); // std::move leaves comment in a "valid but unspecified state" according to the specification.
/* find start of parameter */
while (*t == '=' || *t == ' ' || *t == '\t') t++;

View File

@ -66,6 +66,7 @@ static std::vector<std::string> EscapeQuotesAndSlashesAndSplitOnNewLines(const s
for (auto c : message) {
if (c == '\n') {
messages.emplace_back(std::move(safe_message));
safe_message.clear(); // std::move leaves safe_message in a "valid but unspecified state" according to the specification.
continue;
}