Don't add null characters to the end of the APFloat string buffer.

Report/patch inspiration by Olaf Krzikalla.

llvm-svn: 160744
This commit is contained in:
David Blaikie 2012-07-25 18:04:24 +00:00
parent 959f0b3a07
commit 70fdf72a48
1 changed files with 2 additions and 10 deletions

View 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