Patchwork lib: fwts_framework: free just items in list and not list descriptor

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

Comments

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

Coverity CID #997320: Free of address-of expression

We should be just free'ing the items in the list and not the
list descriptor because that is not on the heap.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_framework.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - May 8, 2013, 2:13 a.m.
On 05/07/2013 03:46 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997320: Free of address-of expression
>
> We should be just free'ing the items in the list and not the
> list descriptor because that is not on the heap.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 67dd3ab..857b54e 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -925,7 +925,7 @@ static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
>   	for (str = (char*)arg; (token = strtok_r(str, ",", &saveptr)) != NULL; str = NULL) {
>   		if (fwts_list_append(list, token) == NULL) {
>   			fprintf(stderr, "Out of memory parsing argument %s\n", arg);
> -			fwts_list_free(list, NULL);
> +			fwts_list_free_items(list, NULL);
>   			return FWTS_ERROR;
>   		}
>   	}
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - May 20, 2013, 7:31 a.m.
On Tue, May 7, 2013 at 3:46 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997320: Free of address-of expression
>
> We should be just free'ing the items in the list and not the
> list descriptor because that is not on the heap.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_framework.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 67dd3ab..857b54e 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -925,7 +925,7 @@ static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
>         for (str = (char*)arg; (token = strtok_r(str, ",", &saveptr)) != NULL; str = NULL) {
>                 if (fwts_list_append(list, token) == NULL) {
>                         fprintf(stderr, "Out of memory parsing argument %s\n", arg);
> -                       fwts_list_free(list, NULL);
> +                       fwts_list_free_items(list, NULL);
>                         return FWTS_ERROR;
>                 }
>         }
> --
> 1.8.1.2
>

Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index 67dd3ab..857b54e 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -925,7 +925,7 @@  static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
 	for (str = (char*)arg; (token = strtok_r(str, ",", &saveptr)) != NULL; str = NULL) {
 		if (fwts_list_append(list, token) == NULL) {
 			fprintf(stderr, "Out of memory parsing argument %s\n", arg);
-			fwts_list_free(list, NULL);
+			fwts_list_free_items(list, NULL);
 			return FWTS_ERROR;
 		}
 	}