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 | 5846239e1669f8047ad095f18d05e4a04bd61079 (patch) | |
tree | dbaea486ac8b000547343821e609407ffe304da5 | |
parent | d974524d3da2cb17dda908e7a78d3542e4c67ef6 (diff) | |
download | bcm5719-llvm-5846239e1669f8047ad095f18d05e4a04bd61079.tar.gz bcm5719-llvm-5846239e1669f8047ad095f18d05e4a04bd61079.zip |
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.
llvm-svn: 176721
-rw-r--r-- | llvm/lib/IR/Metadata.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index d751064e222..0228aeb31f5 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/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); } |