Don't add null characters to the end of the APFloat string buffer.
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 25 Jul 2012 18:04:24 +0000 (18:04 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 25 Jul 2012 18:04:24 +0000 (18:04 +0000)
Report/patch inspiration by Olaf Krzikalla.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160744 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APFloat.cpp

index 409d4fbd0ae5ca444a1a96162812aa731e5ef953..9f5ca3e3d526f353a482d49b9b64163a208157c0 100644 (file)
@@ -3278,16 +3278,8 @@ APFloat::APFloat(double d) : exponent2(0), sign2(0) {
 }
 
 namespace {
-  static void append(SmallVectorImpl<char> &Buffer,
-                     unsigned N, const char *Str) {
-    unsigned Start = Buffer.size();
-    Buffer.set_size(Start + N);
-    memcpy(&Buffer[Start], Str, N);
-  }
-
-  template <unsigned N>
-  void append(SmallVectorImpl<char> &Buffer, const char (&Str)[N]) {
-    append(Buffer, N, Str);
+  void append(SmallVectorImpl<char> &Buffer, StringRef Str) {
+    Buffer.append(Str.begin(), Str.end());
   }
 
   /// Removes data from the given significand until it is no more