[PATCH] D63788: llvm-c-test avoid calling malloc(0)
Andus Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 4 07:38:13 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365144: llvm-c-test avoid calling malloc(0) (authored by andusy, committed by ).
Herald added a subscriber: wuzish.
Changed prior to commit:
https://reviews.llvm.org/D63788?vs=207068&id=208040#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63788/new/
https://reviews.llvm.org/D63788
Files:
llvm/trunk/tools/llvm-c-test/attributes.c
Index: llvm/trunk/tools/llvm-c-test/attributes.c
===================================================================
--- llvm/trunk/tools/llvm-c-test/attributes.c
+++ llvm/trunk/tools/llvm-c-test/attributes.c
@@ -29,9 +29,12 @@
for (Idx = LLVMAttributeFunctionIndex, ParamCount = LLVMCountParams(F);
Idx <= ParamCount; ++Idx) {
int AttrCount = LLVMGetAttributeCountAtIndex(F, Idx);
- LLVMAttributeRef *Attrs =
- (LLVMAttributeRef *)malloc(AttrCount * sizeof(LLVMAttributeRef));
- assert(Attrs);
+ LLVMAttributeRef *Attrs = 0;
+ if (AttrCount) {
+ Attrs =
+ (LLVMAttributeRef *)malloc(AttrCount * sizeof(LLVMAttributeRef));
+ assert(Attrs);
+ }
LLVMGetAttributesAtIndex(F, Idx, Attrs);
free(Attrs);
}
@@ -61,9 +64,12 @@
ParamCount = LLVMCountParams(F);
Idx <= ParamCount; ++Idx) {
int AttrCount = LLVMGetCallSiteAttributeCount(I, Idx);
- LLVMAttributeRef *Attrs = (LLVMAttributeRef *)malloc(
- AttrCount * sizeof(LLVMAttributeRef));
- assert(Attrs);
+ LLVMAttributeRef *Attrs = 0;
+ if (AttrCount) {
+ Attrs = (LLVMAttributeRef *)malloc(
+ AttrCount * sizeof(LLVMAttributeRef));
+ assert(Attrs);
+ }
LLVMGetCallSiteAttributes(I, Idx, Attrs);
free(Attrs);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63788.208040.patch
Type: text/x-patch
Size: 1450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190704/7c3dca6e/attachment.bin>
More information about the llvm-commits
mailing list