From eeb18ee6e3b1b07574a7f0fda2c0c20ac3f773df Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 11 Feb 2015 16:03:21 +0100 Subject: Ensure all dynrefs with the same target resolve to the same object when one name points to multiple objects --- src/modules.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/modules.cpp') diff --git a/src/modules.cpp b/src/modules.cpp index d7aa534ab..6510c9423 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -684,8 +684,10 @@ void dynamic_reference_base::SetProvider(const std::string& newname) void dynamic_reference_base::resolve() { - std::multimap::iterator i = ServerInstance->Modules->DataProviders.find(name); - if (i != ServerInstance->Modules->DataProviders.end()) + // Because find() may return any element with a matching key in case count(key) > 1 use lower_bound() + // to ensure a dynref with the same name as another one resolves to the same object + std::multimap::iterator i = ServerInstance->Modules.DataProviders.lower_bound(name); + if ((i != ServerInstance->Modules.DataProviders.end()) && (i->first == this->name)) value = static_cast(i->second); else value = NULL; -- cgit v1.2.3