-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove (wrong) C API fixes from llvm-api and patch LLVM instead.
- Loading branch information
Showing
3 changed files
with
48 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
commit b1cfc87891b4cb41ec94457a0d42d8c1fd57faf6 | ||
Author: whitequark <whitequark@whitequark.org> | ||
Date: Sat Nov 12 03:38:23 2016 +0000 | ||
|
||
[C API] Fix several null pointer dereferences. | ||
|
||
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286704 91177308-0d34-0410-b5e6-96231b3b80d8 | ||
|
||
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp | ||
index 1cf17b1f311..a969e08cabc 100644 | ||
--- a/lib/IR/Core.cpp | ||
+++ b/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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters