threads / patch / 59833

patchFix memory leak in get_reachable_subset

Subject: [PATCH] Fix memory leak in get_reachable_subset

## tl;dr

5 messages between Jun 3, 2023 and Jun 5, 2023. Diffs are folded; open one to read it.

replies: 4people: 4as markdown or json

Mike Hommey· Jun 3, 2023, 00:28 UTC · lore
Signed-off-by: Mike Hommey <mh@glandium.org>
---
 commit-reach.c | 2 ++
 1 file changed, 2 insertions(+)
Show changes to commit-reach.c +2 −0
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.41.0.6.ge371d37104
Junio C Hamano· Jun 3, 2023, 02:02 UTC · re: Mike Hommey · lore

Re: [PATCH] Fix memory leak in get_reachable_subset

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

As most lines in the affected function seems to come from your fcb2c076 (commit-reach: implement get_reachable_subset, 2018-11-02), I'll redirect the review of this patch to you.

Thanks.
Show 15 quoted lines
>  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);
René Scharfe· Jun 3, 2023, 06:02 UTC · re: Junio C Hamano · lore

Re: [PATCH] Fix memory leak in get_reachable_subset

Am 03.06.23 um 04:02 schrieb Junio C Hamano:
Show 8 quoted lines
> Mike Hommey <mh@glandium.org> writes:
>
>> Signed-off-by: Mike Hommey <mh@glandium.org>
>> ---
>
> As most lines in the affected function seems to come from your
> fcb2c076 (commit-reach: implement get_reachable_subset, 2018-11-02),
> I'll redirect the review of this patch to you.

Stolee reviewed it already when the patch was sent the first time, here: https://lore.kernel.org/git/20230421234409.1925489-1-mh@glandium.org/T/#u

Show 15 quoted lines
>
> Thanks.
>
>>  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);

Makes sense: The loop that dequeues would end before consuming all items when all "to" commits are found to be reachable.

>> +
>>  	clear_commit_marks_many(nr_to, to, PARENT1);
>>  	clear_commit_marks_many(nr_from, from, PARENT2);
Junio C Hamano· Jun 4, 2023, 04:42 UTC · re: René Scharfe · lore

Re: [PATCH] Fix memory leak in get_reachable_subset

René Scharfe <l.s.r@web.de> writes:
> Stolee reviewed it already when the patch was sent the first time, here:
> https://lore.kernel.org/git/20230421234409.1925489-1-mh@glandium.org/T/#u
OK.  Thanks.
Derrick Stolee· Jun 5, 2023, 15:50 UTC · re: Junio C Hamano · lore

Re: [PATCH] Fix memory leak in get_reachable_subset

On 6/4/2023 12:42 AM, Junio C Hamano wrote:
Show 6 quoted lines
> René Scharfe <l.s.r@web.de> writes:
> 
>> Stolee reviewed it already when the patch was sent the first time, here:
>> https://lore.kernel.org/git/20230421234409.1925489-1-mh@glandium.org/T/#u
> 
> OK.  Thanks.

Thanks for finding this link. I saw this patch and immediately thought, "I made this mistake a _second_ time?"

The patch continues to look good to me.

Thanks, -Stolee

← back to recent threads