1
0
forked from 0ad/0ad

Fix a possible source of segmentation fault in our custom version of ObjectIdCache.

Patch by echotangoecho, refs #4053

This was SVN commit r18757.
This commit is contained in:
Nicolas Auvray 2016-09-24 13:48:11 +00:00
parent fd8f689f35
commit 172c222e9b

View File

@ -37,7 +37,6 @@ public:
ObjectIdCache(shared_ptr<ScriptRuntime> rt)
: table_(nullptr), m_rt(rt)
{
JS_AddExtraGCRootsTracer(m_rt->m_rt, ObjectIdCache::Trace, this);
}
~ObjectIdCache()
@ -46,9 +45,8 @@ public:
{
m_rt->AddDeferredFinalizationObject(std::shared_ptr<void>((void*)table_, DeleteTable));
table_ = nullptr;
JS_RemoveExtraGCRootsTracer(m_rt->m_rt, ObjectIdCache::Trace, this);
}
JS_RemoveExtraGCRootsTracer(m_rt->m_rt, ObjectIdCache::Trace, this);
}
bool init()
@ -57,6 +55,7 @@ public:
return true;
table_ = new Table(js::SystemAllocPolicy());
JS_AddExtraGCRootsTracer(m_rt->m_rt, ObjectIdCache::Trace, this);
return table_ && table_->init(32);
}