Skip to content
Permalink
Browse files

Fix overlay regression that in some cases prevented injection into de…

…vices in myCreateDevice(/Ex)

Incorrect checking for element existence in the std::map using the operator[]
caused interfaces to be added to the device map that weren't actually injected
to yet.

To minimize code impact before DX11 branch merge replace correct existence
checks triggering the bug with checks on whether there's a valid handle
(!= NULL) present for that device in the map. This way the default constructed
(and hence NULL) elements caused by the use of the operator[] are harmless.

For the future we'll have to decide whether we accept additional elements for
"simpler" coding or use the "logically cleaner" style of using find and
iterators.
  • Loading branch information...
hacst committed Oct 23, 2013
1 parent a6f7610 commit 07e055fff12b0e2f890eec47ee9e4ae19e53fa6a
Showing with 2 additions and 2 deletions.
  1. +2 −2 overlay/d3d9.cpp
@@ -700,7 +700,7 @@ static HRESULT __stdcall myCreateDevice(IDirect3D9 * id3d, UINT Adapter, D3DDEVT
idd->AddRef();
ds->initRefCount = idd->Release();

if (devMap.find(idd) != devMap.end()) {
if (devMap[idd] != NULL) {
ods("Device exists in devMap already - canceling injection into device");
delete ds;
return hr;
@@ -764,7 +764,7 @@ static HRESULT __stdcall myCreateDeviceEx(IDirect3D9Ex * id3d, UINT Adapter, D3D
idd->AddRef();
ds->initRefCount = idd->Release();

if (devMap.find(idd) != devMap.end()) {
if (devMap[idd] != NULL) {
ods("Device exists in devMap already - canceling injection into device");
delete ds;
return hr;

0 comments on commit 07e055f

Please sign in to comment.
You can’t perform that action at this time.