Re: [PATCH] Handle (unlikely) allocation failure in getent wrapper
Hi!
On Thu, 2025-04-24 at 10:44:41 +0900, Simon Richter wrote:
> ---
> lib/compat/getent.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lib/compat/getent.c b/lib/compat/getent.c
> index e5c55a5f9..a7bb06328 100644
> --- a/lib/compat/getent.c
> +++ b/lib/compat/getent.c
> @@ -212,6 +212,8 @@ fgetgrent(FILE *fp)
> gr.gr_passwd = ent_empty_str;
> gr.gr_gid = 0;
> gr.gr_mem = alloc_subfields(0, &gr_mem, &gr_mem_len);
> + if (gr.gr_mem == NULL)
> + return NULL;
> gr.gr_mem[0] = NULL;
> } else {
> PARSE_FIELD_STR(gr.gr_passwd);
Nice catch! I've merged (and pushed) a patch based on this one covering
all allocation failures.
Thanks,
Guillem
Reply to: