Bug 1060419 - use result of SprintfLiteral in Printf.cpp; r=froydnj
authorTom Tromey <tom@tromey.com>
Thu, 05 Jan 2017 08:15:48 -0700
changeset 372584 1f08f556c880d7afcd297032e7d055339d5ac6ad
parent 372583 e0e53d202593b66dd0b77623275b214da8570b36
child 372585 ee190ce6c8ce2db44d0005863695c02eb6cd153d
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1060419
milestone54.0a1
Bug 1060419 - use result of SprintfLiteral in Printf.cpp; r=froydnj MozReview-Commit-ID: HSHAeKVu6PU
mozglue/misc/Printf.cpp
--- a/mozglue/misc/Printf.cpp
+++ b/mozglue/misc/Printf.cpp
@@ -271,19 +271,20 @@ mozilla::PrintfTarget::cvt_f(double d, c
     {
         const char* p = fin;
         while (*p) {
             MOZ_ASSERT(*p != 'L');
             p++;
         }
     }
 #endif
-    SprintfLiteral(fout, fin, d);
+    size_t len = SprintfLiteral(fout, fin, d);
+    MOZ_ASSERT(len <= sizeof(fout));
 
-    return emit(fout, strlen(fout));
+    return emit(fout, len);
 }
 
 /*
  * Convert a string into its printable form.  "width" is the output
  * width. "prec" is the maximum number of characters of "s" to output,
  * where -1 means until NUL.
  */
 bool