Bug 1131382 - Don't trust numCompartments when getting compartment stats (r=luke)

This commit is contained in:
Bill McCloskey 2015-02-11 12:54:07 -08:00
parent c8281d0595
commit d57d6ba75c
2 changed files with 7 additions and 7 deletions

View File

@ -168,12 +168,11 @@ JS_GetEmptyString(JSRuntime *rt)
JS_PUBLIC_API(bool)
JS_GetCompartmentStats(JSRuntime *rt, CompartmentStatsVector &stats)
{
if (!stats.resizeUninitialized(rt->numCompartments))
return false;
size_t pos = 0;
for (CompartmentsIter c(rt, WithAtoms); !c.done(); c.next()) {
CompartmentTimeStats *stat = &stats[pos];
if (!stats.growBy(1))
return false;
CompartmentTimeStats *stat = &stats.back();
stat->time = c.get()->totalTime;
stat->compartment = c.get();
stat->addonId = c.get()->addonId;
@ -184,7 +183,6 @@ JS_GetCompartmentStats(JSRuntime *rt, CompartmentStatsVector &stats)
} else {
strcpy(stat->compartmentName, "<unknown>");
}
pos++;
}
return true;
}

View File

@ -774,7 +774,9 @@ struct JSRuntime : public JS::shadow::Runtime,
return numExclusiveThreads > 0;
}
/* How many compartments there are across all zones. */
// How many compartments there are across all zones. This number includes
// ExclusiveContext compartments, so it isn't necessarily equal to the
// number of compartments visited by CompartmentsIter.
size_t numCompartments;
/* Locale-specific callbacks for string conversion. */