diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-02-11 16:03:21 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-02-11 16:03:21 +0100 |
commit | eeb18ee6e3b1b07574a7f0fda2c0c20ac3f773df (patch) | |
tree | 1f959724b0c1fc135b853514f454ef5d7f196cb3 /src | |
parent | 9b99c5ad31eb8de222d2b3aa1daa9412f0b25857 (diff) |
Ensure all dynrefs with the same target resolve to the same object when one name points to multiple objects
Diffstat (limited to 'src')
-rw-r--r-- | src/modules.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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<std::string, ServiceProvider*>::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<std::string, ServiceProvider*>::iterator i = ServerInstance->Modules.DataProviders.lower_bound(name); + if ((i != ServerInstance->Modules.DataProviders.end()) && (i->first == this->name)) value = static_cast<DataProvider*>(i->second); else value = NULL; |