bug 1218576 - Ensure Telemetry IDs coming from IPC are valid r=gfritzsche

I saw a one-off crash on try in internal_GetHistogramByEnumId. Not reproducible
but maybe possible if we're trying to accumulate using an invalid ID. So let's
guard against that.

MozReview-Commit-ID: Ei6eTlV91mJ
This commit is contained in:
Chris H-C 2016-07-28 12:22:06 -04:00
Родитель 6e50e9e79a
Коммит b7121fe41a
1 изменённых файлов: 10 добавлений и 0 удалений

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

@ -2159,6 +2159,11 @@ TelemetryHistogram::AccumulateChild(const nsTArray<Accumulation>& aAccumulations
return;
}
for (uint32_t i = 0; i < aAccumulations.Length(); ++i) {
bool isValid = internal_IsHistogramEnumId(aAccumulations[i].mId);
MOZ_ASSERT(isValid);
if (!isValid) {
continue;
}
internal_AccumulateChild(aAccumulations[i].mId, aAccumulations[i].mSample);
}
}
@ -2172,6 +2177,11 @@ TelemetryHistogram::AccumulateChildKeyed(const nsTArray<KeyedAccumulation>& aAcc
return;
}
for (uint32_t i = 0; i < aAccumulations.Length(); ++i) {
bool isValid = internal_IsHistogramEnumId(aAccumulations[i].mId);
MOZ_ASSERT(isValid);
if (!isValid) {
continue;
}
internal_AccumulateChildKeyed(aAccumulations[i].mId,
aAccumulations[i].mKey,
aAccumulations[i].mSample);