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

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: gotwebd repo_commit memory leak
To:
gameoftrees@openbsd.org
Date:
Mon, 2 Dec 2024 19:42:36 +0100

Download raw body.

Thread
On 02/12/24 18:53, Stefan Sperling wrote:
> This looks like a memory leak, doesn't it? I assume if a repo_commit
> is not put on the list of repo_commits then we should free it.

yep, if we don't move it to the tailq it should be free'd

> ok?

ok op@

> diff /home/stsp/src/got
> path + /home/stsp/src/got
> commit - de4367eca3fd8fad9122290f92c24cc3a5039cdd
> blob - e6b67696b6074e0499b029da5f51a883bf9c1e89
> file + gotwebd/got_operations.c
> --- gotwebd/got_operations.c
> +++ gotwebd/got_operations.c
> @@ -421,30 +421,31 @@ got_get_repo_commits(struct request *c, size_t limit)
>  		error = got_init_repo_commit(&repo_commit);
>  		if (error)
>  			goto done;
>  
>  		error = got_get_repo_commit(c, repo_commit, commit,
>  		    &refs, &next_id);
>  		if (error) {
>  			gotweb_free_repo_commit(repo_commit);
>  			goto done;
>  		}
>  
>  		if (--limit == 0 && chk_next) {
>  			t->more_id = strdup(repo_commit->commit_id);
>  			if (t->more_id == NULL)
>  				error = got_error_from_errno("strdup");
> +			gotweb_free_repo_commit(repo_commit);
>  			goto done;
>  		}
>  
>  		TAILQ_INSERT_TAIL(&t->repo_commits, repo_commit, entry);
>  
>  		if (limit == 0)
>  			goto done;
>  
>  		if (commit) {
>  			got_object_commit_close(commit);
>  			commit = NULL;
>  		}
>  	}
>   done:
>  	if (ref)
>