diff mbox

[7/7] libsepol: destroy the copied va_list

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

Commit Message

Nicolas Iooss May 26, 2018, 6:42 p.m. UTC
va_copy()'s manpage [1] states:

    Each invocation of va_copy() must be matched by a corresponding
    invocation of va_end() in the same function.

create_str_helper() is using va_copy() without va_end(). Add the missing
call.

[1] https://linux.die.net/man/3/va_copy

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libsepol/src/kernel_to_common.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

William Roberts May 29, 2018, 2:46 p.m. UTC | #1
ack

On Sat, May 26, 2018 at 11:42 AM, Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
> va_copy()'s manpage [1] states:
>
>     Each invocation of va_copy() must be matched by a corresponding
>     invocation of va_end() in the same function.
>
> create_str_helper() is using va_copy() without va_end(). Add the missing
> call.
>
> [1] https://linux.die.net/man/3/va_copy
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> ---
>  libsepol/src/kernel_to_common.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libsepol/src/kernel_to_common.c b/libsepol/src/kernel_to_common.c
> index 342bc3c91df9..7c5699c52c95 100644
> --- a/libsepol/src/kernel_to_common.c
> +++ b/libsepol/src/kernel_to_common.c
> @@ -80,10 +80,13 @@ static char *create_str_helper(const char *fmt, int num, va_list vargs)
>                 goto exit;
>         }
>
> +       va_end(vargs2);
> +
>         return str;
>
>  exit:
>         free(str);
> +       va_end(vargs2);
>         return NULL;
>  }
>
> --
> 2.17.0
>
>
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to Selinux-request@tycho.nsa.gov.
diff mbox

Patch

diff --git a/libsepol/src/kernel_to_common.c b/libsepol/src/kernel_to_common.c
index 342bc3c91df9..7c5699c52c95 100644
--- a/libsepol/src/kernel_to_common.c
+++ b/libsepol/src/kernel_to_common.c
@@ -80,10 +80,13 @@  static char *create_str_helper(const char *fmt, int num, va_list vargs)
 		goto exit;
 	}
 
+	va_end(vargs2);
+
 	return str;
 
 exit:
 	free(str);
+	va_end(vargs2);
 	return NULL;
 }