From: Bernhard Voelker <[email protected]>

src/selinux.c (defaultcon): In edge cases where scontext is
allocated, while tcontext is not, ensure both are deallocated.
Also remove the redundant NULL guard to context_free().
(restorecon_private): Likewise.
---
 src/selinux.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/selinux.c b/src/selinux.c
index bbb9999..e708b55 100644
--- a/src/selinux.c
+++ b/src/selinux.c
@@ -128,10 +128,8 @@ defaultcon (char const *path, mode_t mode)
 
 //  printf("defaultcon %s %s\n", path, context_str(tcontext));
 quit:
-  if (scontext)
-    context_free (scontext);
-  if (scontext)
-    context_free (tcontext);
+  context_free (scontext);
+  context_free (tcontext);
   freecon (scon);
   freecon (tcon);
   return rc;
@@ -218,10 +216,8 @@ restorecon_private (char const *path, bool preserve)
 //  printf("restorcon %s %s\n", path, context_str(tcontext));
 quit:
   close (fd);
-  if (scontext)
-    context_free (scontext);
-  if (scontext)
-    context_free (tcontext);
+  context_free (scontext);
+  context_free (tcontext);
   freecon (scon);
   freecon (tcon);
   return rc;
-- 
1.7.6.4


Reply via email to