From 4c3b875a0b3e57f0b9c42bfc14b1e48cadef73b3 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Tue, 29 Mar 2016 05:25:17 +0000 Subject: [PATCH] BitcodeReader: Allow METADATA_STRINGS to only have !"" Support parsing a METADATA_STRINGS record that only has a single piece of metadata, !"". Fixes a corner case in r264551. llvm-svn: 264699 --- lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- test/Bitcode/metadata-only-empty-string.ll | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/Bitcode/metadata-only-empty-string.ll diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index cb2784ff204..72ac217bef2 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1899,7 +1899,7 @@ std::error_code BitcodeReader::parseMetadataStrings(ArrayRef Record, unsigned StringsOffset = Record[1]; if (!NumStrings) return error("Invalid record: metadata strings with no strings"); - if (StringsOffset >= Blob.size()) + if (StringsOffset > Blob.size()) return error("Invalid record: metadata strings corrupt offset"); StringRef Lengths = Blob.slice(0, StringsOffset); diff --git a/test/Bitcode/metadata-only-empty-string.ll b/test/Bitcode/metadata-only-empty-string.ll new file mode 100644 index 00000000000..f8331e35985 --- /dev/null +++ b/test/Bitcode/metadata-only-empty-string.ll @@ -0,0 +1,7 @@ +; RUN: llvm-as < %s | llvm-dis | FileCheck %s + +; CHECK: !named = !{!0} +!named = !{!0} + +; CHECK: !0 = !{!""} +!0 = !{!""}