[llvm] r295142 - Revert r295138: Instead of a series of string operations, use snprintf().
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 17:48:34 PST 2017
Author: ruiu
Date: Tue Feb 14 19:48:33 2017
New Revision: 295142
URL: http://llvm.org/viewvc/llvm-project?rev=295142&view=rev
Log:
Revert r295138: Instead of a series of string operations, use snprintf().
This broke buildbots.
Modified:
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=295142&r1=295141&r2=295142&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Tue Feb 14 19:48:33 2017
@@ -434,8 +434,10 @@ void WinCOFFObjectWriter::SetSectionName
uint64_t StringTableEntry = Strings.getOffset(S.Name);
if (StringTableEntry <= Max7DecimalOffset) {
- snprintf(S.Header.Name, sizeof(S.Header.Name), "/%" PRIu64,
- StringTableEntry);
+ SmallVector<char, COFF::NameSize> Buffer;
+ Twine('/').concat(Twine(StringTableEntry)).toVector(Buffer);
+ assert(Buffer.size() <= COFF::NameSize && Buffer.size() >= 2);
+ std::memcpy(S.Header.Name, Buffer.data(), Buffer.size());
return;
}
if (StringTableEntry <= MaxBase64Offset) {
More information about the llvm-commits
mailing list