>From 8769b66e1e05f5fdb46221f4a49cef58abaa0b0c Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Wed, 10 Oct 2018 17:01:43 -0600 Subject: [PATCH] samacls tests: free memory under lint Avoids false-positives under ASAN and provides better usage examples. Initially reported by deltatau in https://bugs.gnu.org/32685 . Discussed in gnulib at https://lists.gnu.org/r/bug-gnulib/2018-10/msg00026.html . * tests/test-sameacls.c (main): Call free() and acl_free() as needed. --- tests/test-sameacls.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test-sameacls.c b/tests/test-sameacls.c index 51196e3a8..7f0ee6579 100644 --- a/tests/test-sameacls.c +++ b/tests/test-sameacls.c @@ -84,6 +84,10 @@ main (int argc, char *argv[]) fflush (stderr); abort (); } +#ifdef lint + free (contents1); + free (contents2); +#endif } /* Compare the access permissions of the two files, including ACLs. */ @@ -218,6 +222,12 @@ main (int argc, char *argv[]) return 1; } } +#ifdef lint + acl_free (acl1); + acl_free (acl2); + acl_free (text1); + acl_free (text2); +#endif } #elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ int count1; @@ -287,6 +297,10 @@ main (int argc, char *argv[]) return 1; } } +#ifdef lint + free (entries1); + free (entries2); +#endif } # ifdef ACE_GETACL count1 = acl (file1, ACE_GETACLCNT, 0, NULL); @@ -366,6 +380,10 @@ main (int argc, char *argv[]) return 1; } } +#ifdef lint + free (entries1); + free (entries2); +#endif } # endif #elif HAVE_GETACL /* HP-UX */ @@ -438,6 +456,10 @@ main (int argc, char *argv[]) return 1; } } +#ifdef lint + free (entries1); + free (entries2); +#endif } # if HAVE_ACLV_H /* HP-UX >= 11.11 */ @@ -511,6 +533,10 @@ main (int argc, char *argv[]) return 1; } } +#ifdef lint + free (entries1); + free (entries2); +#endif } # endif #elif HAVE_ACLX_GET /* AIX */ @@ -687,6 +713,10 @@ main (int argc, char *argv[]) return 1; } } +#ifdef lint + free (entries1); + free (entries2); +#endif } #endif } -- 2.11.0