public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6641] testsuite: add test coverage for analyzer leak false +ve [PR105906] Date: Mon, 13 Mar 2023 18:54:55 +0000 (GMT) [thread overview] Message-ID: <20230313185455.3119E3858422@sourceware.org> (raw) 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; +}
reply other threads:[~2023-03-13 18:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230313185455.3119E3858422@sourceware.org \ --to=dmalcolm@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).