git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin: submodule--helper: Add allocation check of module_cb structure objects may be helpful in case of allocation failure

From
Bagas Sanjaya <bagasdotme@gmail.com>
Date
Nov 22, 2022, 08:08 UTC
Message-ID
<6c81f4b0-065f-01db-09ef-6ad9e3b0b39c@gmail.com>
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?
Show 16 quoted lines
> 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
Previous: Junio C Hamano
Message 3 of 3 in “builtin: submodule--helper: Add allocation check of module_cb structure objects may be helpful in case of allocation failure”
  1. builtin: submodule--helper: Add allocation check of module_cb structure objects may be helpful in case of allocation failureLi kunyu, Nov 22, 2022
  2. Junio C HamanoNov 22, 2022
  3. Bagas SanjayaNov 22, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.