# [PATCH] Fix memory leak in get_reachable_subset

4 messages from 2023-04-22 to 2023-04-24. Participants: Mike Hommey, Derrick Stolee, Junio C Hamano.
Thread: https://gitlist.dev/t/59632

## Mike Hommey, 2023-04-21 23:44

Subject: [PATCH] Fix memory leak in get_reachable_subset
Message-ID: <20230421234409.1925489-1-mh@glandium.org>
URL: https://gitlist.dev/e/20230421234409.1925489-1-mh%40glandium.org

```
---
 commit-reach.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/commit-reach.c b/commit-reach.c
index 70bde8af05..f15d84566b 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -944,6 +944,8 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
 		}
 	}
 
+	clear_prio_queue(&queue);
+
 	clear_commit_marks_many(nr_to, to, PARENT1);
 	clear_commit_marks_many(nr_from, from, PARENT2);
 
-- 
2.39.0.1.g6739ec1790


```

## Derrick Stolee, 2023-04-24 15:21

Subject: Re: [PATCH] Fix memory leak in get_reachable_subset
Message-ID: <d2825134-61db-9da4-450c-f027117b3d48@github.com>
URL: https://gitlist.dev/e/d2825134-61db-9da4-450c-f027117b3d48%40github.com
In-Reply-To: <20230421234409.1925489-1-mh@glandium.org>

```
On 4/21/2023 7:44 PM, Mike Hommey wrote:
> @@ -944,6 +944,8 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
>  		}
>  	}
>  
> +	clear_prio_queue(&queue);
> +

Thanks. This is a leak that has existed since the method was first
created in fcb2c0769db (commit-reach: implement get_reachable_subset,
2018-11-02). I appreciate the attention to detail.

-Stolee

```

## Junio C Hamano, 2023-04-24 16:09

Subject: Re: [PATCH] Fix memory leak in get_reachable_subset
Message-ID: <xmqqbkjdgt36.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqbkjdgt36.fsf%40gitster.g
In-Reply-To: <20230421234409.1925489-1-mh@glandium.org>

```
Mike Hommey <mh@glandium.org> writes:

> ---
>  commit-reach.c | 2 ++
>  1 file changed, 2 insertions(+)

Missing sign-off?

[jc: adding the author of fcb2c076 (commit-reach: implement
get_reachable_subset, 2018-11-02) to the CC list]

> diff --git a/commit-reach.c b/commit-reach.c
> index 70bde8af05..f15d84566b 100644
> --- a/commit-reach.c
> +++ b/commit-reach.c
> @@ -944,6 +944,8 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
>  		}
>  	}
>  
> +	clear_prio_queue(&queue);
> +
>  	clear_commit_marks_many(nr_to, to, PARENT1);
>  	clear_commit_marks_many(nr_from, from, PARENT2);

Looking good.

```

## Mike Hommey, 2023-04-24 20:41

Subject: Re: [PATCH] Fix memory leak in get_reachable_subset
Message-ID: <20230424204114.53di55n22c5zpbyb@glandium.org>
URL: https://gitlist.dev/e/20230424204114.53di55n22c5zpbyb%40glandium.org
In-Reply-To: <xmqqbkjdgt36.fsf@gitster.g>

```
On Mon, Apr 24, 2023 at 09:09:33AM -0700, Junio C Hamano wrote:
> Mike Hommey <mh@glandium.org> writes:
> 
> > ---
> >  commit-reach.c | 2 ++
> >  1 file changed, 2 insertions(+)
> 
> Missing sign-off?

Gah. Sorry, I forgot it in this and another patch I sent a few days
ago ([PATCH] Handle compiler versions containing a dash)

Do you want full resends or is it okay if I just add

  Signed-off-by: Mike Hommey <mh@glandium.org>

here?

Mike

```
