* [PATCH] fixed testcase fail gcc.dg/analyzer/pr103526.c leak
@ 2021-12-30 2:21 shihua
2021-12-30 13:51 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: shihua @ 2021-12-30 2:21 UTC (permalink / raw)
To: gcc-patches; +Cc: lazyparser, yulong, sinan, jiawei, dmalcolm, LiaoShihua
From: LiaoShihua <shihua@iscas.ac.cn>
following 'false' branch in line 20, 'tmp.word_state' leaks in line 26. So free 'tmp.word_state' before return 'rval'.
gcc/testsuite\ChangeLog:
* gcc.dg/analyzer/pr103526.c:
---
gcc/testsuite/gcc.dg/analyzer/pr103526.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr103526.c b/gcc/testsuite/gcc.dg/analyzer/pr103526.c
index 39d60fd853e..7df2e4e7576 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr103526.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr103526.c
@@ -22,7 +22,8 @@ game_new(void)
if ((rval = malloc(sizeof(*rval))) == NULL)
goto err;
memcpy(rval, &tmp, sizeof(*rval));
-
+
+ free(tmp.word_state);
return (rval);
err:
free(tmp.word_state);
--
2.31.1.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fixed testcase fail gcc.dg/analyzer/pr103526.c leak
2021-12-30 2:21 [PATCH] fixed testcase fail gcc.dg/analyzer/pr103526.c leak shihua
@ 2021-12-30 13:51 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-12-30 13:51 UTC (permalink / raw)
To: shihua, gcc-patches; +Cc: sinan, jiawei, yulong
On 12/29/2021 7:21 PM, shihua@iscas.ac.cn wrote:
> From: LiaoShihua <shihua@iscas.ac.cn>
>
> following 'false' branch in line 20, 'tmp.word_state' leaks in line 26. So free 'tmp.word_state' before return 'rval'.
>
> gcc/testsuite\ChangeLog:
>
> * gcc.dg/analyzer/pr103526.c:
Umm, isn't the whole point of the test to verify that the analyzer
properly detects the non-free'd pointer as escaping via the return value?
Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-30 13:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30 2:21 [PATCH] fixed testcase fail gcc.dg/analyzer/pr103526.c leak shihua
2021-12-30 13:51 ` Jeff Law
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).