Bug 1428612 - Part 2: Add an assertion to check the histogram name pointer. r=gfritzsche

This adds a dignostic assertion that the name pointer is actually within the
static name table.

--HG--
extra : rebase_source : 4f82f72c83444a3ccd5be270080837f60110766e
This commit is contained in:
Eric Rahm 2018-01-17 16:52:37 -08:00
Родитель 67e0ab19b7
Коммит ba599d7f41
1 изменённых файлов: 5 добавлений и 0 удалений

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

@ -1741,6 +1741,11 @@ void TelemetryHistogram::InitializeGlobalState(bool canRecordBase,
for (uint32_t i = 0; i < HistogramCount; i++) {
auto name = gHistogramInfos[i].name();
// Make sure the name pointer is in a valid region. See bug 1428612.
MOZ_DIAGNOSTIC_ASSERT(name >= gHistogramStringTable);
MOZ_DIAGNOSTIC_ASSERT(
uintptr_t(name) < (uintptr_t(gHistogramStringTable) + sizeof(gHistogramStringTable)));
nsCString wrappedName;
wrappedName.AssignLiteral(name, strlen(name));
gNameToHistogramIDMap.Put(wrappedName, HistogramID(i));