Bug 1060419 - use result of SprintfLiteral in Printf.cpp; r?froydnj draft
authorTom Tromey <tom@tromey.com>
Thu, 05 Jan 2017 08:15:48 -0700
changeset 486168 dee774fbdd73b50d1d857e9da96363e4c6899909
parent 486167 5c4e3b7fd5fb1c6d15d04627ae15c370a097ea9a
child 486169 2beed2133c922f3d4bd8fe8a34385bd3873c0ff9
push id45909
push userbmo:ttromey@mozilla.com
push dateFri, 17 Feb 2017 16:00:11 +0000
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