Bug 1395524 - Use AppendFloat when converting the float interval to the env var string. r=njn
authorMarkus Stange <mstange@themasta.com>
Thu, 31 Aug 2017 13:36:44 +0200
changeset 657397 3f011ef0427917868dae16b57d15683abed1e5cd
parent 657396 28d54da51af50d43fdc6d25b6a9f27aa64ed1be4
child 657398 8b08fc01370011cbe4c87dd742584b9f3ecbf999
push id77508
push userbmo:emilio@crisal.io
push dateFri, 01 Sep 2017 11:17:48 +0000
reviewersnjn
bugs1395524
milestone57.0a1
Bug 1395524 - Use AppendFloat when converting the float interval to the env var string. r=njn MozReview-Commit-ID: GsW9W3aJZTg
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2512,18 +2512,25 @@ AutoSetProfilerEnvVarsForChildProcess::A
     return;
   }
 
   PR_SetEnv("MOZ_PROFILER_STARTUP=1");
   SprintfLiteral(mSetEntries, "MOZ_PROFILER_STARTUP_ENTRIES=%d",
                  ActivePS::Entries(lock));
   PR_SetEnv(mSetEntries);
 
-  SprintfLiteral(mSetInterval, "MOZ_PROFILER_STARTUP_INTERVAL=%f",
-                 ActivePS::Interval(lock));
+  // Use AppendFloat instead of SprintfLiteral with %f because the decimal
+  // separator used by %f is locale-dependent. But the string we produce needs
+  // to be parseable by strtod, which only accepts the period character as a
+  // decimal separator. AppendFloat always uses the period character.
+  nsCString setInterval;
+  setInterval.AppendLiteral("MOZ_PROFILER_STARTUP_INTERVAL=");
+  setInterval.AppendFloat(ActivePS::Interval(lock));
+  strncpy(mSetInterval, setInterval.get(), MOZ_ARRAY_LENGTH(mSetInterval));
+  mSetInterval[MOZ_ARRAY_LENGTH(mSetInterval) - 1] = '\0';
   PR_SetEnv(mSetInterval);
 
   SprintfLiteral(mSetFeaturesBitfield,
                  "MOZ_PROFILER_STARTUP_FEATURES_BITFIELD=%d",
                  ActivePS::Features(lock));
   PR_SetEnv(mSetFeaturesBitfield);
 
   std::string filtersString;