From 5846239e1669f8047ad095f18d05e4a04bd61079 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 8 Mar 2013 21:08:23 +0000 Subject: [PATCH] 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 --- llvm/lib/IR/Metadata.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index d751064..0228aeb 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(this), i); } -- 2.7.4