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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
> ---
>  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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux