[llvm] r347528 - [MetadataTest] Fix off-by-one strncpy warning reported by gcc8. (NFC)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 25 11:38:02 PST 2018
Author: fhahn
Date: Sun Nov 25 11:38:02 2018
New Revision: 347528
URL: http://llvm.org/viewvc/llvm-project?rev=347528&view=rev
Log:
[MetadataTest] Fix off-by-one strncpy warning reported by gcc8. (NFC)
Modified:
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=347528&r1=347527&r2=347528&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Sun Nov 25 11:38:02 2018
@@ -147,11 +147,9 @@ TEST_F(MDStringTest, CreateSame) {
// Test that MDString prints out the string we fed it.
TEST_F(MDStringTest, PrintingSimple) {
- char *str = new char[13];
- strncpy(str, "testing 1 2 3", 13);
- MDString *s = MDString::get(Context, StringRef(str, 13));
- strncpy(str, "aaaaaaaaaaaaa", 13);
- delete[] str;
+ char str[14] = "testing 1 2 3";
+ MDString *s = MDString::get(Context, StringRef(&str[0], 13));
+ strncpy(str, "aaaaaaaaaaaaa", 14);
std::string Str;
raw_string_ostream oss(Str);
More information about the llvm-commits
mailing list