public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6641] testsuite: add test coverage for analyzer leak false +ve [PR105906]
@ 2023-03-13 18:54 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2023-03-13 18:54 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:23532dac3f602d6c29f5b7062c7fe30905061764

commit r13-6641-g23532dac3f602d6c29f5b7062c7fe30905061764
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Mon Mar 13 14:53:05 2023 -0400

    testsuite: add test coverage for analyzer leak false +ve [PR105906]
    
    Adding regression test coverage; I believe I fixed this leak
    false positive with r13-5113-g688fc162b76dc6.
    
    gcc/testsuite/ChangeLog:
            PR analyzer/105906
            * gcc.dg/analyzer/leak-pr105906.c: New test.
    
    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

Diff:
---
 gcc/testsuite/gcc.dg/analyzer/leak-pr105906.c | 32 +++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/analyzer/leak-pr105906.c b/gcc/testsuite/gcc.dg/analyzer/leak-pr105906.c
new file mode 100644
index 00000000000..72901e4d1eb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/leak-pr105906.c
@@ -0,0 +1,32 @@
+/* { dg-additional-options "-Wno-analyzer-too-complex" } */
+
+#define NULL ((void *)0)
+
+#define LEN 64
+
+char **
+epystr_explode(const char *delim, char *str)
+{
+	char **out = NULL;
+	int i;
+
+	if (str == NULL || delim == NULL)
+		return NULL;
+
+	out = __builtin_malloc(LEN * sizeof(char *));
+	if (out == NULL)
+		return NULL;
+
+	for (i = 0; i < LEN; i++) {
+		out[i] = __builtin_strdup("bla");
+		if (out[i] == NULL) /* { dg-bogus "leak" } */
+			goto freem;
+	}
+	return out;
+
+freem:
+	while (--i >= 0)
+		__builtin_free(out[i]);
+	__builtin_free(out);
+	return NULL;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-13 18:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 18:54 [gcc r13-6641] testsuite: add test coverage for analyzer leak false +ve [PR105906] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).