Bug 1459144 - Allocate enough memory for all the processes when deserializing histograms. draft
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Tue, 22 May 2018 15:17:02 +0000
changeset 798682 23c3371a5d585689e69581a396e777b9863b32e6
parent 798068 f85be0c4f0562ea59a91000883e0e7848491837c
child 798683 c5288f7a6abd63d798e1afbbc7b75e161d4865c3
push id110825
push userbmo:jrediger@mozilla.com
push dateWed, 23 May 2018 10:19:35 +0000
bugs1459144
milestone62.0a1
Bug 1459144 - Allocate enough memory for all the processes when deserializing histograms.
toolkit/components/telemetry/TelemetryHistogram.cpp
--- 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);