diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-31 04:20:23 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-31 04:20:23 +0000 |
commit | cc8c673e61c05dcfd4aaf34f0d1a1454991bc795 (patch) | |
tree | 0603d47401e1dc1f124da9255aeb3105b4355c93 | |
parent | 8f4397799f9eebdc149754c539619ccbed578b90 (diff) | |
download | llvm-cc8c673e61c05dcfd4aaf34f0d1a1454991bc795.tar.gz llvm-cc8c673e61c05dcfd4aaf34f0d1a1454991bc795.tar.bz2 llvm-cc8c673e61c05dcfd4aaf34f0d1a1454991bc795.tar.xz |
Fix a use after free on invalid input.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193737 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 6 | ||||
-rw-r--r-- | test/Bitcode/invalid.ll | 7 | ||||
-rw-r--r-- | test/Bitcode/invalid.ll.bc | bin | 0 -> 332 bytes |
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index e408cd1f98..1661990f06 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -623,11 +623,7 @@ bool BitcodeReader::ParseAttrKind(uint64_t Code, Attribute::AttrKind *Kind) { *Kind = Attribute::ZExt; return false; default: - std::string Buf; - raw_string_ostream fmt(Buf); - fmt << "Unknown attribute kind (" << Code << ")"; - fmt.flush(); - return Error(Buf.c_str()); + return Error("Unknown attribute kind"); } } diff --git a/test/Bitcode/invalid.ll b/test/Bitcode/invalid.ll new file mode 100644 index 0000000000..49189bf8c0 --- /dev/null +++ b/test/Bitcode/invalid.ll @@ -0,0 +1,7 @@ +; RUN: not llvm-dis < %s.bc 2>&1 | FileCheck %s + +; CHECK: llvm-dis: Unknown attribute kind + +; invalid.ll.bc has an invalid attribute number. +; The test checks that LLVM reports the error and doesn't access freed memory +; in doing so. diff --git a/test/Bitcode/invalid.ll.bc b/test/Bitcode/invalid.ll.bc Binary files differnew file mode 100644 index 0000000000..b8b1c47b6a --- /dev/null +++ b/test/Bitcode/invalid.ll.bc |