Skip to content

Commit

Permalink
Merge pull request #534 from jordan-woyak/ini-file-fix
Browse files Browse the repository at this point in the history
Store ini sections in a std::list to prevent pointer invalidation.
  • Loading branch information
lioncash committed Jun 24, 2014
2 parents 4138702 + 5163695 commit 832d0bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Common/IniFile.cpp
Expand Up @@ -233,7 +233,7 @@ IniFile::Section* IniFile::GetOrCreateSection(const std::string& sectionName)
if (!section)
{
sections.push_back(Section(sectionName));
section = &sections[sections.size() - 1];
section = &sections.back();
}
return section;
}
Expand Down Expand Up @@ -323,7 +323,7 @@ bool IniFile::GetLines(const std::string& sectionName, std::vector<std::string>*

void IniFile::SortSections()
{
std::sort(sections.begin(), sections.end());
sections.sort();
}

bool IniFile::Load(const std::string& filename, bool keep_current_data)
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Common/IniFile.h
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <cstring>
#include <list>
#include <map>
#include <string>
#include <vector>
Expand Down Expand Up @@ -116,7 +117,7 @@ class IniFile
Section* GetOrCreateSection(const std::string& section);

private:
std::vector<Section> sections;
std::list<Section> sections;

const Section* GetSection(const std::string& section) const;
Section* GetSection(const std::string& section);
Expand Down

0 comments on commit 832d0bb

Please sign in to comment.