diff --git a/js/src/gc/Statistics.cpp b/js/src/gc/Statistics.cpp index be9fd4824234..f9afc2d04caf 100644 --- a/js/src/gc/Statistics.cpp +++ b/js/src/gc/Statistics.cpp @@ -782,7 +782,7 @@ Statistics::~Statistics() fclose(fp); } -/* static */ void +/* static */ bool Statistics::initialize() { for (size_t i = 0; i < PHASE_LIMIT; i++) { @@ -806,7 +806,8 @@ Statistics::initialize() MOZ_ASSERT(phases[child].parent == PHASE_MULTI_PARENTS); int j = child; do { - dagDescendants[phaseExtra[parent].dagSlot].append(Phase(j)); + if (!dagDescendants[phaseExtra[parent].dagSlot].append(Phase(j))) + return false; j++; } while (j != PHASE_LIMIT && phases[j].parent != PHASE_MULTI_PARENTS); } @@ -815,7 +816,8 @@ Statistics::initialize() // Fill in the depth of each node in the tree. Multi-parented nodes // have depth 0. mozilla::Vector stack; - stack.append(PHASE_LIMIT); // Dummy entry to avoid special-casing the first node + if (!stack.append(PHASE_LIMIT)) // Dummy entry to avoid special-casing the first node + return false; for (int i = 0; i < PHASE_LIMIT; i++) { if (phases[i].parent == PHASE_NO_PARENT || phases[i].parent == PHASE_MULTI_PARENTS) @@ -826,9 +828,11 @@ Statistics::initialize() stack.popBack(); } phaseExtra[i].depth = stack.length(); - stack.append(Phase(i)); + if (!stack.append(Phase(i))) + return false; } + return true; } JS::GCSliceCallback diff --git a/js/src/gc/Statistics.h b/js/src/gc/Statistics.h index 3f78225ef689..b0cb5c123d7c 100644 --- a/js/src/gc/Statistics.h +++ b/js/src/gc/Statistics.h @@ -162,7 +162,7 @@ struct Statistics /* Create a convenient type for referring to tables of phase times. */ using PhaseTimeTable = int64_t[NumTimingArrays][PHASE_LIMIT]; - static void initialize(); + static bool initialize(); explicit Statistics(JSRuntime* rt); ~Statistics(); diff --git a/js/src/vm/Initialization.cpp b/js/src/vm/Initialization.cpp index 6001808180d0..502d640aa008 100644 --- a/js/src/vm/Initialization.cpp +++ b/js/src/vm/Initialization.cpp @@ -104,7 +104,8 @@ JS_Init(void) if (!FutexRuntime::initialize()) return false; - js::gcstats::Statistics::initialize(); + if (!js::gcstats::Statistics::initialize()) + return false; libraryInitState = InitState::Running; return true;