aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/malloc.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-04-26 05:08:26 +0000
committerTed Kremenek <kremenek@apple.com>2012-04-26 05:08:26 +0000
commit8f40afbf7740c39fccaa4b8cc5aa2814d5ed6fdc (patch)
treee09b738cdf30b7eb3a7926f8872e6a193305bedf /test/Analysis/malloc.c
parentbefc6d2eae269efa2da9c81d0be8dba144a74d47 (diff)
[analyzer] check lazy bindings in RegionStore first before looking for default values. Fixes <rdar://problem/11269741>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/malloc.c')
-rw-r--r--test/Analysis/malloc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c
index 3b4712320b..32c6171f8c 100644
--- a/test/Analysis/malloc.c
+++ b/test/Analysis/malloc.c
@@ -760,6 +760,22 @@ void radar10978247_positive(int myValueSize) {
return;
}
+// <rdar://problem/11269741> Previously this triggered a false positive
+// because malloc() is known to return uninitialized memory and the binding
+// of 'o' to 'p->n' was not getting propertly handled. Now we report a leak.
+struct rdar11269741_a_t {
+ struct rdar11269741_b_t {
+ int m;
+ } n;
+};
+
+int rdar11269741(struct rdar11269741_b_t o)
+{
+ struct rdar11269741_a_t *p = (struct rdar11269741_a_t *) malloc(sizeof(*p));
+ p->n = o;
+ return p->n.m; // expected-warning {{leak}}
+}
+
// ----------------------------------------------------------------------------
// Below are the known false positives.