Bug 1459144 - Allocate enough memory for all the processes when deserializing histograms. r?chutten draft
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Tue, 22 May 2018 17:12:59 +0200
changeset 799210 9d5d4f08a61d54476b87546a52b8b4fac41c7447
parent 797745 77c06979d9e88979ec96263eccdbd750cb9221a4
child 799211 56a8b262c6348fad021e693912135d0b6c12775d
push id110969
push userbmo:alessio.placitelli@gmail.com
push dateThu, 24 May 2018 07:46:56 +0000
reviewerschutten
bugs1459144
milestone62.0a1
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
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);