[rtems commit] libtests/calloc.c: Fix reported memory leak

Joel Sherrill joel at rtems.org
Wed Nov 3 13:38:27 UTC 2021


Module:    rtems
Branch:    master
Commit:    19c101281a4371909901b5d6ed26cba7296ce21c
Changeset: http://git.rtems.org/rtems/commit/?id=19c101281a4371909901b5d6ed26cba7296ce21c

Author:    zack leung <zakthertemsdev at gmail.com>
Date:      Mon Oct 18 23:46:10 2021 +0000

libtests/calloc.c: Fix reported memory leak

This fix came from Code Inspector, flagged by one of the analysis that
was done.

This test code is compiled only but better to address the issues so
future static analysis reports will not include it.

---

 testsuites/libtests/POSIX/calloc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testsuites/libtests/POSIX/calloc.c b/testsuites/libtests/POSIX/calloc.c
index bd04faa..a7537c8 100644
--- a/testsuites/libtests/POSIX/calloc.c
+++ b/testsuites/libtests/POSIX/calloc.c
@@ -16,6 +16,8 @@ int
 main (void)
 {
   void *foo = calloc (42, 43);
+  int rc = (foo != NULL);
+  free(foo);
 
-  return (foo != NULL);
+  return rc;
 }



More information about the vc mailing list