Index | Thread | Search

From:
Kirill A. Korinsky <kirill@korins.ky>
Subject:
Re: patch: bail out in fetchname() if out_of_memory
To:
"Omar Polo" <op@omarpolo.com>
Cc:
tech@openbsd.org
Date:
Thu, 05 Nov 2026 12:05:38 +0100

Download raw body.

Thread
On Thu, 05 Nov 2026 11:46:17 +0100,
"Omar Polo" <op@omarpolo.com> wrote:
> 
> savestr() is basically xstrdup() with an optional path for "plan A"
> where it returns NULL instead of fatal().
> 
> afaik, this is the only place where we don't check out_of_mem after
> savestr().  bailing out seems nicer than crashing on the next line.
> 
> ok?
>

OK kirill@

But, personally, we should nuke all that out_of_mem and replace it by fatal()

> diff /home/op/w/patch
> path + /home/op/w/patch
> commit - df4e48f5c58474cd91cf83065e253c9efdfe5d93
> blob - c94a3f2beb10a18d9687941619e72776bf160a7f
> file + util.c
> --- util.c
> +++ util.c
> @@ -356,6 +356,8 @@ fetchname(const char *at, bool *exists, int strip_lead
>  	if (strnEQ(at, _PATH_DEVNULL, sizeof(_PATH_DEVNULL) - 1))
>  		return NULL;
>  	name = fullname = t = savestr(at);
> +	if (out_of_mem)
> +		return NULL;
>  
>  	tab = strchr(t, '\t') != NULL;
>  	/* Strip off up to `strip_leading' path components and NUL terminate. */
> 

-- 
wbr, Kirill