diff mbox

[1/6] semodule_package: do not leak memory when using -u or -s

Message ID 20170227203935.23674-1-nicolas.iooss@m4x.org (mailing list archive)
State Not Applicable
Headers show

Commit Message

Nicolas Iooss Feb. 27, 2017, 8:39 p.m. UTC
When using -u and -s options, semodule_package's main() allocates
user_extra and seusers to hold the argument values. These allocated
memory blocks are not freed when main() exits, which leads gcc's Address
Sanitizer to report a memory leak. This occurs for example when building
refpolicy base.pp module.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 semodule-utils/semodule_package/semodule_package.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

James Carter March 1, 2017, 4:35 p.m. UTC | #1
On 02/27/2017 03:39 PM, Nicolas Iooss wrote:
> When using -u and -s options, semodule_package's main() allocates
> user_extra and seusers to hold the argument values. These allocated
> memory blocks are not freed when main() exits, which leads gcc's Address
> Sanitizer to report a memory leak. This occurs for example when building
> refpolicy base.pp module.
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

I applied all six of these patches.

Thanks,
Jim

> ---
>  semodule-utils/semodule_package/semodule_package.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/semodule-utils/semodule_package/semodule_package.c b/semodule-utils/semodule_package/semodule_package.c
> index e472054826a3..a25daf59f9e7 100644
> --- a/semodule-utils/semodule_package/semodule_package.c
> +++ b/semodule-utils/semodule_package/semodule_package.c
> @@ -257,5 +257,7 @@ int main(int argc, char **argv)
>  	free(file_contexts);
>  	free(outfile);
>  	free(module);
> +	free(seusers);
> +	free(user_extra);
>  	exit(0);
>  }
>
diff mbox

Patch

diff --git a/semodule-utils/semodule_package/semodule_package.c b/semodule-utils/semodule_package/semodule_package.c
index e472054826a3..a25daf59f9e7 100644
--- a/semodule-utils/semodule_package/semodule_package.c
+++ b/semodule-utils/semodule_package/semodule_package.c
@@ -257,5 +257,7 @@  int main(int argc, char **argv)
 	free(file_contexts);
 	free(outfile);
 	free(module);
+	free(seusers);
+	free(user_extra);
 	exit(0);
 }