summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-06-08 00:25:08 +0000
committerZachary Turner <zturner@google.com>2016-06-08 00:25:08 +0000
commitd2b2bfed9465847baa82a314d4da161b368395bb (patch)
treea394e7cbf39161112109b311381b2afc0e14de4c /llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
parenta483eae2ff21d238ba3a872ef72ec7943acaefa2 (diff)
downloadbcm5719-llvm-d2b2bfed9465847baa82a314d4da161b368395bb.tar.gz
bcm5719-llvm-d2b2bfed9465847baa82a314d4da161b368395bb.zip
[pdb] Try to fix use after free.
llvm-svn: 272078
Diffstat (limited to 'llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp')
-rw-r--r--llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index b287243d0c4..20d08f5c8ff 100644
--- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -191,10 +191,12 @@ Error LLVMOutputStyle::dumpStreamData() {
uint32_t StreamCount = File.getNumStreams();
StringRef DumpStreamStr = opts::DumpStreamDataIdx;
uint32_t DumpStreamNum;
- if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum) ||
- DumpStreamNum >= StreamCount)
+ if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum))
return Error::success();
+ if (DumpStreamNum >= StreamCount)
+ return make_error<RawError>(raw_error_code::no_stream);
+
MappedBlockStream S(llvm::make_unique<IndexedStreamData>(DumpStreamNum, File),
File);
codeview::StreamReader R(S);
@@ -238,6 +240,8 @@ Error LLVMOutputStyle::dumpNamedStream() {
InfoStream &IS = InfoS.get();
uint32_t NameStreamIndex = IS.getNamedStreamIndex(opts::DumpStreamDataName);
+ if (NameStreamIndex == 0 || NameStreamIndex >= File.getNumStreams())
+ return make_error<RawError>(raw_error_code::no_stream);
if (NameStreamIndex != 0) {
std::string Name("Stream '");
OpenPOWER on IntegriCloud