[PATCH] Clean double free in copy_dive_site()

Dirk Hohndel dirk at hohndel.org
Tue Jul 7 10:39:05 PDT 2015


On Tue, Jul 07, 2015 at 07:35:26PM +0200, Salvador Cuñat wrote:
> This makes subsurface crash by simply clicking a dive in the list.

I didn't get that crash (which is surprising, looking at the code), but
you are right, good catch. The pointer is freed in the free_taxonomy()
call already.

/D

> Signed-off-by: Salvador Cuñat <salvador.cunat at gmail.com>
> ---
>  divesite.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/divesite.c b/divesite.c
> index 5abab76..5c96bb2 100644
> --- a/divesite.c
> +++ b/divesite.c
> @@ -171,7 +171,6 @@ void copy_dive_site(struct dive_site *orig, struct dive_site *copy)
>  	copy->uuid = orig->uuid;
>  	if (orig->taxonomy.category == NULL) {
>  		free_taxonomy(copy->taxonomy.category);
> -		free(copy->taxonomy.category);
>  		copy->taxonomy.category = NULL;
>  		copy->taxonomy.nr = 0;
>  	} else {
> -- 
> 2.1.4
> 


More information about the subsurface mailing list