summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-c-test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-c-test')
-rw-r--r--llvm/tools/llvm-c-test/attributes.c3
-rw-r--r--llvm/tools/llvm-c-test/echo.cpp3
2 files changed, 5 insertions, 1 deletions
diff --git a/llvm/tools/llvm-c-test/attributes.c b/llvm/tools/llvm-c-test/attributes.c
index c6beab1d31b..c7bc0d3c87b 100644
--- a/llvm/tools/llvm-c-test/attributes.c
+++ b/llvm/tools/llvm-c-test/attributes.c
@@ -14,6 +14,7 @@
#include "llvm-c-test.h"
+#include <assert.h>
#include <stdlib.h>
int llvm_test_function_attributes(void) {
@@ -30,6 +31,7 @@ int llvm_test_function_attributes(void) {
int AttrCount = LLVMGetAttributeCountAtIndex(F, Idx);
LLVMAttributeRef *Attrs =
(LLVMAttributeRef *)malloc(AttrCount * sizeof(LLVMAttributeRef));
+ assert(Attrs);
LLVMGetAttributesAtIndex(F, Idx, Attrs);
free(Attrs);
}
@@ -61,6 +63,7 @@ int llvm_test_callsite_attributes(void) {
int AttrCount = LLVMGetCallSiteAttributeCount(I, Idx);
LLVMAttributeRef *Attrs = (LLVMAttributeRef *)malloc(
AttrCount * sizeof(LLVMAttributeRef));
+ assert(Attrs);
LLVMGetCallSiteAttributes(I, Idx, Attrs);
free(Attrs);
}
diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp
index 05d80363162..db7211a3eab 100644
--- a/llvm/tools/llvm-c-test/echo.cpp
+++ b/llvm/tools/llvm-c-test/echo.cpp
@@ -90,7 +90,8 @@ struct TypeCloner {
unsigned ParamCount = LLVMCountParamTypes(Src);
LLVMTypeRef* Params = nullptr;
if (ParamCount > 0) {
- Params = (LLVMTypeRef*) malloc(ParamCount * sizeof(LLVMTypeRef));
+ Params = static_cast<LLVMTypeRef*>(
+ safe_malloc(ParamCount * sizeof(LLVMTypeRef)));
LLVMGetParamTypes(Src, Params);
for (unsigned i = 0; i < ParamCount; i++)
Params[i] = Clone(Params[i]);
OpenPOWER on IntegriCloud