Bug 1369994 - Ensure template objects for typed arrays are initialized properly before exposing them to GC. r=sfink

This commit is contained in:
Jon Coppeard 2017-06-26 20:15:41 -04:00
Родитель 8a5ba394b7
Коммит 549947fd25
1 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -578,11 +578,6 @@ class TypedArrayObjectTemplate : public TypedArrayObject
RootedObject tmp(cx, NewBuiltinClassInstance(cx, clasp, allocKind, newKind)); RootedObject tmp(cx, NewBuiltinClassInstance(cx, clasp, allocKind, newKind));
if (!tmp) if (!tmp)
return nullptr; return nullptr;
if (script && !ObjectGroup::setAllocationSiteObjectGroup(cx, script, pc, tmp,
newKind == SingletonObject))
{
return nullptr;
}
TypedArrayObject* tarray = &tmp->as<TypedArrayObject>(); TypedArrayObject* tarray = &tmp->as<TypedArrayObject>();
initTypedArraySlots(cx, tarray, len); initTypedArraySlots(cx, tarray, len);
@ -592,6 +587,12 @@ class TypedArrayObjectTemplate : public TypedArrayObject
// nullptr and avoid allocating memory that will never be used. // nullptr and avoid allocating memory that will never be used.
tarray->initPrivate(nullptr); tarray->initPrivate(nullptr);
if (script && !ObjectGroup::setAllocationSiteObjectGroup(cx, script, pc, tmp,
newKind == SingletonObject))
{
return nullptr;
}
return tarray; return tarray;
} }