Patchwork utilities: kernelscan: fix memory leak

login
register
mail settings
Submitter Colin King
Date May 7, 2013, 12:20 a.m.
Message ID <1367886028-23855-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/241858/
State Accepted
Headers show

Comments

Colin King - May 7, 2013, 12:20 a.m.
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997339, Resource leak

Fix memory leak, free line when we return.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/utilities/kernelscan.c | 1 +
 1 file changed, 1 insertion(+)
Alex Hung - May 10, 2013, 1:08 a.m.
On 05/07/2013 08:20 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997339, Resource leak
>
> Fix memory leak, free line when we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/utilities/kernelscan.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 95dc8a2..9acaa4e 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -777,6 +777,7 @@ static int parse_kernel_message(parser *p, token *t)
>   	for (;;) {
>   		ret = get_token(p, t);
>   		if (ret == EOF) {
> +			free(line);
>   			return EOF;
>   		}
>
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - May 16, 2013, 4:05 a.m.
On 05/07/2013 08:20 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997339, Resource leak
>
> Fix memory leak, free line when we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/utilities/kernelscan.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 95dc8a2..9acaa4e 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -777,6 +777,7 @@ static int parse_kernel_message(parser *p, token *t)
>   	for (;;) {
>   		ret = get_token(p, t);
>   		if (ret == EOF) {
> +			free(line);
>   			return EOF;
>   		}
>
>


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

Patch

diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
index 95dc8a2..9acaa4e 100644
--- a/src/utilities/kernelscan.c
+++ b/src/utilities/kernelscan.c
@@ -777,6 +777,7 @@  static int parse_kernel_message(parser *p, token *t)
 	for (;;) {
 		ret = get_token(p, t);
 		if (ret == EOF) {
+			free(line);
 			return EOF;
 		}