-
Notifications
You must be signed in to change notification settings - Fork 26.7k
commit-graph: fix memory leak when fill_oids_from_packs()
failed
#1957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/submit |
Submitted as pull.1957.git.git.1746712275566.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, Patrick Steinhardt wrote (reply to this): On Thu, May 08, 2025 at 01:51:15PM +0000, Lidong Yan via GitGitGadget wrote:
> From: Lidong Yan <502024330056@smail.nju.edu.cn>
>
> In commit-graph.c line 1930, if open_pack_index failed, memory allocated
> in line 1925 by add_packed_git will leak. Simply add close_pack and
> free(p) will solve this problem.
The same comments apply to this commit message as Junio has already
mentioned in other commits. We don't typically point to exact line
numbers, but rather mention for example the function name.
> diff --git a/commit-graph.c b/commit-graph.c
> index 6394752b0b0..93d867770b0 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -1929,6 +1929,8 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
> }
> if (open_pack_index(p)) {
> ret = error(_("error opening index for %s"), packname.buf);
> + close_pack(p);
> + free(p);
> goto cleanup;
> }
> for_each_object_in_pack(p, add_packed_commits, ctx,
The change itself looks correct to me. Thanks!
Patrick |
User |
On the Git mailing list, lidongyan wrote (reply to this): Ok, I will replace line number to fill_oids_from_packs in next patch.
> 2025年5月9日 13:38,Patrick Steinhardt <ps@pks.im> 写道:
>
> On Thu, May 08, 2025 at 01:51:15PM +0000, Lidong Yan via GitGitGadget wrote:
>> From: Lidong Yan <502024330056@smail.nju.edu.cn>
>>
>> In commit-graph.c line 1930, if open_pack_index failed, memory allocated
>> in line 1925 by add_packed_git will leak. Simply add close_pack and
>> free(p) will solve this problem.
>
> The same comments apply to this commit message as Junio has already
> mentioned in other commits. We don't typically point to exact line
> numbers, but rather mention for example the function name.
>
>> diff --git a/commit-graph.c b/commit-graph.c
>> index 6394752b0b0..93d867770b0 100644
>> --- a/commit-graph.c
>> +++ b/commit-graph.c
>> @@ -1929,6 +1929,8 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
>> }
>> if (open_pack_index(p)) {
>> ret = error(_("error opening index for %s"), packname.buf);
>> + close_pack(p);
>> + free(p);
>> goto cleanup;
>> }
>> for_each_object_in_pack(p, add_packed_commits, ctx,
>
> The change itself looks correct to me. Thanks!
>
> Patrick
>
|
72402ab
to
190961f
Compare
/submit |
Submitted as pull.1957.v2.git.git.1746774869081.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, Patrick Steinhardt wrote (reply to this): On Fri, May 09, 2025 at 07:14:28AM +0000, Lidong Yan via GitGitGadget wrote:
> From: Lidong Yan <502024330056@smail.nju.edu.cn>
>
> In commit-graph.c:fill_oids_from_packs, if open_pack_index failed,
> memory allocated and returned by add_packed_git will leak. Simply
> add close_pack and free(p) will solve this problem.
One more thing that I missed in the first review: the commit subject
should mention the subsystem as prefix, not the specific function. So It
should e.g. read:
commit-grap: fix memory leak when `fill_oids_from_packs()` fails
Patrick |
In commit-graph.c:fill_oids_from_packs, if open_pack_index failed, memory allocated and returned by add_packed_git will leak. Simply add close_pack and free(p) will solve this problem. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
190961f
to
e0dfe69
Compare
/submit |
Submitted as pull.1957.v3.git.git.1746779435536.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
fill_oids_from_packs()
failed
This patch series was integrated into seen via d691b68. |
On the Git mailing list, Junio C Hamano wrote (reply to this): "Lidong Yan via GitGitGadget" <gitgitgadget@gmail.com> writes:
> ## Commit message ##
> - fill_oids_from_packs: fix memory leak when fill_oids_from_packs failed
> + commit-grap: fix memory leak when `fill_oids_from_packs()` fails
I'll amend the title to add missing "h" after "grap" while queuing.
Thanks. |
This branch is now known as |
This patch series was integrated into seen via c20ea1d. |
There was a status update in the "New Topics" section about the branch Leakfix. Will merge to 'next'. source: <pull.1957.v3.git.git.1746779435536.gitgitgadget@gmail.com> |
This patch series was integrated into seen via 68a59b0. |
This patch series was integrated into seen via 359e7a1. |
This patch series was integrated into next via 972bbc7. |
There was a status update in the "Cooking" section about the branch Leakfix. Will merge to 'master'. source: <pull.1957.v3.git.git.1746779435536.gitgitgadget@gmail.com> |
This patch series was integrated into seen via 4fb22b4. |
This patch series was integrated into seen via f2c28d2. |
This patch series was integrated into seen via cdcee3d. |
There was a status update in the "Cooking" section about the branch Leakfix. Will merge to 'master'. source: <pull.1957.v3.git.git.1746779435536.gitgitgadget@gmail.com> |
This patch series was integrated into seen via b6fa7fb. |
This patch series was integrated into master via b6fa7fb. |
This patch series was integrated into next via b6fa7fb. |
Closed via b6fa7fb. |
In commit-graph.c:fill_oids_from_packs, if open_pack_index failed, memory allocated in line 1925 by add_packed_git will leak. Simply add close_pack and free(p) will solve this problem.
cc: Patrick Steinhardt ps@pks.im