Fix crash when unbinding from Delegate from other thread during invocation

Caused by `callee` being invalid thus it's better to read function pointer again to ensure that both are valid before calling function.
This commit is contained in:
Wojtek Figat
2023-02-17 10:31:49 +01:00
parent ec8df18ee4
commit 2338e03554

View File

@@ -617,12 +617,11 @@ public:
FunctionType* bindings = (FunctionType*)Platform::AtomicRead((intptr volatile*)&_ptr);
for (intptr i = 0; i < size; i++)
{
auto function = (StubSignature)Platform::AtomicRead((intptr volatile*)&bindings[i]._function);
if (function != nullptr)
{
auto callee = (void*)Platform::AtomicRead((intptr volatile*)&bindings[i]._callee);
auto function = (StubSignature)Platform::AtomicRead((intptr volatile*)&bindings->_function);
auto callee = (void*)Platform::AtomicRead((intptr volatile*)&bindings->_callee);
if (function != nullptr && function == (StubSignature)Platform::AtomicRead((intptr volatile*)&bindings->_function))
function(callee, Forward<Params>(params)...);
}
++bindings;
}
}
};