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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: gotwebd: plug leaks in got_get_repo_tags
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Fri, 2 Sep 2022 11:51:19 +0200

Download raw body.

Thread
On Fri, Sep 02, 2022 at 11:49:21AM +0200, Omar Polo wrote:
> On 2022/09/02 11:45:48 +0200, Stefan Sperling <stsp@stsp.name> wrote:
> > I don't see why it has to be freed inside the loop in first place?
> > Can't we just leave it allocated and free only on exit?
> 
> ah, yes.  it's better like this, thanks!

ok stsp@

> diff b163541dd9b5a61e6be0e3956ab1ed2c591aace5 ac9ca4edfe025b2bb5184778b39330ac8fd330aa
> commit - b163541dd9b5a61e6be0e3956ab1ed2c591aace5
> commit + ac9ca4edfe025b2bb5184778b39330ac8fd330aa
> blob - d8514a11ea110093a8ab4f21841ed7be3cde176e
> blob + 04cc799c9db1c0359740a967662340d9eb76f2cd
> --- gotwebd/got_operations.c
> +++ gotwebd/got_operations.c
> @@ -757,10 +757,8 @@ got_get_repo_tags(struct request *c, int limit)
>  			new_repo_tag->commit_msg = strdup(commit_msg);
>  			if (new_repo_tag->commit_msg == NULL) {
>  				error = got_error_from_errno("strdup");
> -				free(commit_msg0);
>  				goto err;
>  			}
> -			free(commit_msg0);
>  		}
>  
>  		if (limit && --limit == 0) {
> @@ -806,6 +804,7 @@ err:
>  	if (tag)
>  		got_object_tag_close(tag);
>  	got_ref_list_free(&refs);
> +	free(commit_msg0);
>  	free(in_repo_path);
>  	free(repo_path);
>  	free(id);
> 
> 
>