From 40a7eb38375699a9956bbe3cbb713433bf1d7b8c Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Wed, 22 Feb 2012 19:24:52 +0000 Subject: [analyzer] Malloc cleanup: - We should not evaluate strdup in the Malloc Checker, it's the job of CString checker, so just update the RefState to reflect allocated memory. - Refactor to reduce LOC: remove some wrapper auxiliary functions, make all functions return the state and add the transition in one place (instead of in each auxiliary function). llvm-svn: 151188 --- clang/test/Analysis/malloc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/test/Analysis/malloc.c') diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index a38c30a5ed6..1923305fe20 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -671,6 +671,12 @@ int testStrndup(const char *s, unsigned validIndex, unsigned size) { return 1;// expected-warning {{Memory is never released; potential memory leak}} } +void testStrdupContentIsDefined(const char *s, unsigned validIndex) { + char *s2 = strdup(s); + char result = s2[1];// no warning + free(s2); +} + // Below are the known false positives. // TODO: There should be no warning here. This one might be difficult to get rid of. -- cgit v1.2.3