summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2016-11-12 03:38:23 +0000
committerwhitequark <whitequark@whitequark.org>2016-11-12 03:38:23 +0000
commitce9bb1097dc2ce3babed2c4ff1795ffe269104b0 (patch)
treef8c0f842a230f629954e23f99dbdcc3da413be59 /llvm/lib
parent047485ef6984be20cb17be2d3f45ec9b023f8512 (diff)
downloadbcm5719-llvm-ce9bb1097dc2ce3babed2c4ff1795ffe269104b0.tar.gz
bcm5719-llvm-ce9bb1097dc2ce3babed2c4ff1795ffe269104b0.zip
[C API] Fix several null pointer dereferences.
llvm-svn: 286704
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Core.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 1cf17b1f311..a969e08cabc 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -1842,12 +1842,16 @@ void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx) {
auto *ASN = AttributeSetNode::get(unwrap<Function>(F)->getAttributes(), Idx);
+ if (!ASN)
+ return 0;
return ASN->getNumAttributes();
}
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
LLVMAttributeRef *Attrs) {
auto *ASN = AttributeSetNode::get(unwrap<Function>(F)->getAttributes(), Idx);
+ if (!ASN)
+ return;
for (auto A: make_range(ASN->begin(), ASN->end()))
*Attrs++ = wrap(A);
}
@@ -2173,6 +2177,8 @@ unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
LLVMAttributeIndex Idx) {
auto CS = CallSite(unwrap<Instruction>(C));
auto *ASN = AttributeSetNode::get(CS.getAttributes(), Idx);
+ if (!ASN)
+ return 0;
return ASN->getNumAttributes();
}
@@ -2180,6 +2186,8 @@ void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
LLVMAttributeRef *Attrs) {
auto CS = CallSite(unwrap<Instruction>(C));
auto *ASN = AttributeSetNode::get(CS.getAttributes(), Idx);
+ if (!ASN)
+ return;
for (auto A: make_range(ASN->begin(), ASN->end()))
*Attrs++ = wrap(A);
}
OpenPOWER on IntegriCloud