"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: Memory leak in got_fetch_pack()
To:
Mikhail <mp39590@gmail.com>
Cc:
gameoftrees@openbsd.org
Date:
Wed, 23 Mar 2022 21:56:15 +0100

Download raw body.

Thread
On Wed, Mar 23, 2022 at 10:09:27PM +0300, Mikhail wrote:
> During exploration of the code, I came across little memory leak.
> 
> We malloc() the memory in got_object_id_str (lib/fetch.c:489), but never
> free() it.
> 
> Please, assess the patch.

Thanks. I have committed this a moment ago.

> diff refs/heads/main refs/heads/id_str
> blob - e557ed1517eb0150936c27521720d73e1dc76d88
> blob + c6a947cc4002d0ef7d26469a37cfd819bb827897
> --- lib/fetch.c
> +++ lib/fetch.c
> @@ -500,6 +500,8 @@ got_fetch_pack(struct got_object_id **pack_hash, struc
>  		err = got_error_from_errno("asprintf");
>  		goto done;
>  	}
> +	free(id_str);
> +	id_str = NULL;
>  
>  	if (rename(tmppackpath, packpath) == -1) {
>  		err = got_error_from_errno3("rename", tmppackpath, packpath);
> @@ -534,6 +536,7 @@ done:
>  	free(tmppackpath);
>  	free(tmpidxpath);
>  	free(idxpath);
> +	free(id_str);
>  	free(packpath);
>  	free(progress);
>  
> 
>