diff mbox

uefi: uefidump: missing va_end on str == NULL return path

Message ID 1367884572-22996-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King May 6, 2013, 11:56 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997322, Missing varargs init or cleanup (VARARGS)

Coverity detected a missing va_end on the str == NULL error
return path.  Fix this by using va_end() immediately after we
finish using args.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/uefi/uefidump/uefidump.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Alex Hung May 10, 2013, 12:52 a.m. UTC | #1
On 05/07/2013 07:56 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997322, Missing varargs init or cleanup (VARARGS)
>
> Coverity detected a missing va_end on the str == NULL error
> return path.  Fix this by using va_end() immediately after we
> finish using args.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/uefi/uefidump/uefidump.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 771f904..fa914ba 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -60,8 +60,8 @@ static char *uefidump_vprintf(char *str, const char *fmt, ...)
>   	char buffer[4096];
>
>   	va_start(args, fmt);
> -
>   	vsnprintf(buffer, sizeof(buffer), fmt, args);
> +	va_end(args);
>
>   	if (str == NULL)
>   		str = strdup(buffer);
> @@ -72,7 +72,6 @@ static char *uefidump_vprintf(char *str, const char *fmt, ...)
>   		strcat(str, buffer);
>   	}
>
> -	va_end(args);
>   	return str;
>   }
>
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu May 16, 2013, 3:47 a.m. UTC | #2
On 05/07/2013 07:56 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997322, Missing varargs init or cleanup (VARARGS)
>
> Coverity detected a missing va_end on the str == NULL error
> return path.  Fix this by using va_end() immediately after we
> finish using args.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/uefi/uefidump/uefidump.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 771f904..fa914ba 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -60,8 +60,8 @@ static char *uefidump_vprintf(char *str, const char *fmt, ...)
>   	char buffer[4096];
>
>   	va_start(args, fmt);
> -
>   	vsnprintf(buffer, sizeof(buffer), fmt, args);
> +	va_end(args);
>
>   	if (str == NULL)
>   		str = strdup(buffer);
> @@ -72,7 +72,6 @@ static char *uefidump_vprintf(char *str, const char *fmt, ...)
>   		strcat(str, buffer);
>   	}
>
> -	va_end(args);
>   	return str;
>   }
>
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index 771f904..fa914ba 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -60,8 +60,8 @@  static char *uefidump_vprintf(char *str, const char *fmt, ...)
 	char buffer[4096];
 
 	va_start(args, fmt);
-
 	vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
 
 	if (str == NULL)
 		str = strdup(buffer);
@@ -72,7 +72,6 @@  static char *uefidump_vprintf(char *str, const char *fmt, ...)
 		strcat(str, buffer);
 	}
 
-	va_end(args);
 	return str;
 }