diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-03-08 21:08:23 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-03-08 21:08:23 +0000 |
commit | eda774a6c682bc39610130cf8a183e656230c9ef (patch) | |
tree | bf3cd39913f4fa8573f411e733ca93105ed7a7d7 /lib/IR | |
parent | 9333ffb6db95e8ec2e34d2013c4fee47cecc8e91 (diff) | |
download | external_llvm-eda774a6c682bc39610130cf8a183e656230c9ef.zip external_llvm-eda774a6c682bc39610130cf8a183e656230c9ef.tar.gz external_llvm-eda774a6c682bc39610130cf8a183e656230c9ef.tar.bz2 |
Assert to bounds check MDNode::getOperand.
The getOperandPtr utility already bounds checks, but allows one-off-the-end.
This assert should catch the cases that could previously have been dereferencing
these one-off-the-end pointer. Happily, no cases of this came up with this
change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176721 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/Metadata.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index d751064..0228aeb 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -303,6 +303,7 @@ void MDNode::deleteTemporary(MDNode *N) { /// getOperand - Return specified operand. Value *MDNode::getOperand(unsigned i) const { + assert(i < getNumOperands() && "Invalid operand number"); return *getOperandPtr(const_cast<MDNode*>(this), i); } |