Call the relevant scope-data constructor when allocating it, and poison/mark as undefined the memory for the trailing array of BindingNames, ratther than impermissibly PodZero-ing non-trivial classes.

This commit is contained in:
trav90 2018-09-02 18:59:51 -05:00 committed by Roy Tam
commit 78d0ec7fc9
4 changed files with 72 additions and 31 deletions

View file

@ -1453,13 +1453,11 @@ template <typename Scope>
static typename Scope::Data*
NewEmptyBindingData(ExclusiveContext* cx, LifoAlloc& alloc, uint32_t numBindings)
{
using Data = typename Scope::Data;
size_t allocSize = Scope::sizeOfData(numBindings);
auto* bindings = static_cast<typename Scope::Data*>(alloc.alloc(allocSize));
if (!bindings) {
auto* bindings = alloc.allocInSize<Data>(allocSize, numBindings);
if (!bindings)
ReportOutOfMemory(cx);
return nullptr;
}
PodZero(bindings);
return bindings;
}