Bug 1395524 - Use AppendFloat when converting the float interval to the env var string. r?njn draft
authorMarkus Stange <mstange@themasta.com>
Thu, 31 Aug 2017 13:36:44 +0200
changeset 656540 03789073b69e5a55713b2a3f3ef57a7d5f3e1c01
parent 656539 0c2267312d354c23141616ff1b04a296e1900fd9
child 660758 1197c560f24f830780456cbb2fe31ee0b8c0a82a
push id77269
push userbmo:mstange@themasta.com
push dateThu, 31 Aug 2017 11:42:46 +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;