aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/malloc.c')
-rw-r--r--test/Analysis/malloc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c
index b3095e0f30..0321f523a3 100644
--- a/test/Analysis/malloc.c
+++ b/test/Analysis/malloc.c
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,experimental.unix.Malloc -analyzer-store=region -verify %s
+#include "system-header-simulator.h"
+
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
void free(void *);
@@ -237,6 +239,11 @@ void mallocFreeUse_params() {
int *p = malloc(12);
free(p);
myfoo(p); //expected-warning{{Use of dynamically allocated memory after it is freed}}
+}
+
+void mallocFreeUse_params2() {
+ int *p = malloc(12);
+ free(p);
myfooint(*p); //expected-warning{{Use of dynamically allocated memory after it is freed}}
}
@@ -376,6 +383,12 @@ void mallocAssert(int *g) {
return;
}
+void doNotInvalidateWhenPassedToSystemCalls(char *s) {
+ char *p = malloc(12);
+ strlen(p);
+ strcpy(p, s); // expected-warning {{leak}}
+}
+
// Below are the known false positives.
// TODO: There should be no warning here.