git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Li kunyu <kunyu@nfschina.com>, git@vger.kernel.org
Subject: Re: [PATCH] builtin: submodule--helper: Add allocation check of module_cb structure objects may be helpful in case of allocation failure
Date: Tue, 22 Nov 2022 15:08:17 +0700	[thread overview]
Message-ID: <6c81f4b0-065f-01db-09ef-6ad9e3b0b39c@gmail.com> (raw)
In-Reply-To: <20221122031739.3440-1-kunyu@nfschina.com>

On 11/22/22 10:17, Li kunyu wrote:
> The purpose of using temp is unknown, but adding an allocation failure
> report should be helpful.
> 

Don't you understand the code?

> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>  builtin/submodule--helper.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index b63f420ece..2e379623ea 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -1077,6 +1077,9 @@ static void submodule_summary_callback(struct diff_queue_struct *q,
>  		if (!S_ISGITLINK(p->one->mode) && !S_ISGITLINK(p->two->mode))
>  			continue;
>  		temp = (struct module_cb*)malloc(sizeof(struct module_cb));
> +		if (!temp)
> +			 BUG("The module_cb structure object fails to be allocated and the program may terminate abnormally");
> +

Why do you check whenever allocating temp is successful?

-- 
An old man doll... just what I always wanted! - Clara


      parent reply	other threads:[~2022-11-22  8:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-22  3:17 [PATCH] builtin: submodule--helper: Add allocation check of module_cb structure objects may be helpful in case of allocation failure Li kunyu
2022-11-22  4:22 ` Junio C Hamano
2022-11-22  8:08 ` Bagas Sanjaya [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c81f4b0-065f-01db-09ef-6ad9e3b0b39c@gmail.com \
    --to=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kunyu@nfschina.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).