summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-05-13 19:36:00 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-05-16 23:25:26 +0200
commit6ab99f519b3dd96d5d51a8259f07398542dc9473 (patch)
tree839ee57a550b034db081085a1c00d0ba635b8aab /src
parente5c7ef4573adcdcafec7523a77724b171456b215 (diff)
downloadmanaserv-6ab99f519b3dd96d5d51a8259f07398542dc9473.tar.gz
manaserv-6ab99f519b3dd96d5d51a8259f07398542dc9473.tar.xz
manaserv-6ab99f519b3dd96d5d51a8259f07398542dc9473.zip
Don't return configuration value by reference
The lifetime of the default value is often not long enough to survive to the next statement, so returning it by reference is dangereous. At the moment there may not be any place that actually tries to use the returned value as a reference, but it's better not to wait on it to happen. This was already fixed on the client after it lead to strange crashes. Reviewed-by: Jared Adams
Diffstat (limited to 'src')
-rw-r--r--src/common/configuration.cpp4
-rw-r--r--src/common/configuration.hpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/common/configuration.cpp b/src/common/configuration.cpp
index 71c1811..80364b0 100644
--- a/src/common/configuration.cpp
+++ b/src/common/configuration.cpp
@@ -68,8 +68,8 @@ void Configuration::deinitialize()
{
}
-const std::string &Configuration::getValue(const std::string &key,
- const std::string &deflt)
+std::string Configuration::getValue(const std::string &key,
+ const std::string &deflt)
{
std::map<std::string, std::string>::iterator iter = options.find(key);
if (iter == options.end()) return deflt;
diff --git a/src/common/configuration.hpp b/src/common/configuration.hpp
index 791d35c..5e930a9 100644
--- a/src/common/configuration.hpp
+++ b/src/common/configuration.hpp
@@ -38,7 +38,7 @@ namespace Configuration
* @param key option identifier.
* @param deflt default value.
*/
- const std::string &getValue(const std::string &key, const std::string &deflt);
+ std::string getValue(const std::string &key, const std::string &deflt);
/**
* Gets an option as a string.