Bug 1459144 - Allocate enough memory for all the processes when deserializing histograms. r?chutten
This is needed as we might end up serializing only one process, but its id might
be greater than 1 when deserializing.
MozReview-Commit-ID: EzXOOhlNV1Y
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -2807,17 +2807,17 @@ TelemetryHistogram::DeserializeHistogram
// We can't even enumerate the processes in the loaded data, so
// there is nothing we could recover from the persistence file. Bail out.
JS_ClearPendingException(aCx);
return NS_ERROR_FAILURE;
}
// Make sure we have enough storage for all the processes.
PersistedHistogramStorage histogramsToUpdate;
- if (!histogramsToUpdate.resize(processes.length())) {
+ if (!histogramsToUpdate.resize(static_cast<uint32_t>(ProcessID::Count))) {
return NS_ERROR_OUT_OF_MEMORY;
}
// The following block of code attempts to extract as much data as possible
// from the serialized JSON, even in case of light data corruptions: if, for example,
// the data for a single process is corrupted or is in an unexpected form, we press on
// and attempt to load the data for the other processes.
JS::RootedId process(aCx);
@@ -2963,17 +2963,17 @@ TelemetryHistogram::DeserializeKeyedHist
// We can't even enumerate the processes in the loaded data, so
// there is nothing we could recover from the persistence file. Bail out.
JS_ClearPendingException(aCx);
return NS_ERROR_FAILURE;
}
// Make sure we have enough storage for all the processes.
PersistedKeyedHistogramStorage histogramsToUpdate;
- if (!histogramsToUpdate.resize(processes.length())) {
+ if (!histogramsToUpdate.resize(static_cast<uint32_t>(ProcessID::Count))) {
return NS_ERROR_OUT_OF_MEMORY;
}
// The following block of code attempts to extract as much data as possible
// from the serialized JSON, even in case of light data corruptions: if, for example,
// the data for a single process is corrupted or is in an unexpected form, we press on
// and attempt to load the data for the other processes.
JS::RootedId process(aCx);