Commit 2e776f8f authored by James Teh's avatar James Teh
Browse files

Bug 1642141: When clearing the AccessibleHandlerControl Accessible cache, swap...

Bug 1642141: When clearing the AccessibleHandlerControl Accessible cache, swap it into a temporary map first to avoid re-entry into the main map while clearing. r=MarcoZ, a=jcristau

Differential Revision:
parent dee02a3f
......@@ -118,7 +118,18 @@ IMPL_IUNKNOWN1(AccessibleHandlerControl, IHandlerControl)
AccessibleHandlerControl::Invalidate() {
// We can't just call mAccessibleCache.clear() because doing so would release
// remote objects, making remote COM calls. Since this is an STA, an incoming
// COM call might be handled which might marshal an AccessibleHandler,
// which in turn might add itself to mAccessibleCache. Since we'd be in the
// middle of mutating mAccessibleCache, that might cause a crash. Instead,
// swap mAccessibleCache into a temporary map first, which will empty
// mAccessibleCache without releasing remote objects. Once mAccessibleCache
// is empty, it's safe to let the temporary map be destroyed when it goes
// out of scope. Remote calls will be made, but nothing will re-enter
// the temporary map while it's being destroyed.
AccessibleCache oldCache;
return S_OK;
......@@ -85,7 +85,8 @@ class AccessibleHandlerControl final : public IHandlerControl {
UniquePtr<mscom::RegisteredProxy> mIA2Proxy;
UniquePtr<mscom::RegisteredProxy> mHandlerProxy;
// We can't use Gecko APIs in this dll, hence the use of std::unordered_map.
std::unordered_map<long, RefPtr<AccessibleHandler>> mAccessibleCache;
typedef std::unordered_map<long, RefPtr<AccessibleHandler>> AccessibleCache;
AccessibleCache mAccessibleCache;
extern mscom::SingletonFactory<AccessibleHandlerControl> gControlFactory;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment