Index | Thread | Search

From:
"Omar Polo" <op@omarpolo.com>
Subject:
patch: bail out in fetchname() if out_of_memory
To:
tech@openbsd.org
Date:
Thu, 05 Nov 2026 11:46:17 +0100

Download raw body.

Thread
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?

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. */