Skip to content

Commit

Permalink
nvapi: Guard interface registry lookups with a mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
Saancreed authored and jp7677 committed Jan 15, 2025
1 parent 7a91257 commit c4f243d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/nvapi_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ extern "C" {
log::info(str::format("NvAPI_QueryInterface: Ignoring unrecognized entrypoints from ", disabledEnvName, ": ", str::implode(", ", unrecognized)));
}

static std::unordered_map<NvU32, void*> registry;

__declspec(dllexport) void* __cdecl nvapi_QueryInterface(NvU32 id) {
static std::unordered_map<NvU32, void*> registry;
static std::mutex registryMutex;
std::scoped_lock lock(registryMutex);

auto entry = registry.find(id);
if (entry != registry.end())
return entry->second;
Expand Down

0 comments on commit c4f243d

Please sign in to comment.