From: Adhemerval Zanella Date: Fri, 31 Jul 2026 16:37:17 +0000 (+0000) Subject: posix: Use malloc instead of alloca for the glob user name X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0084cbd1835b344eb2cb14f00e486a676fc0623;p=thirdparty%2Fglibc.git posix: Use malloc instead of alloca for the glob user name Use malloc unconditionally. The name is only needed for the passwd lookup that follows, which is far more expensive than the allocation. Checked on x86_64-linux-gnu, aarch64-linux-gnu, and i686-linux-gnu. Reviewed-by: Collin Funk --- diff --git a/posix/glob.c b/posix/glob.c index 0e9bf02bb4..a3c1f888d5 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -828,19 +828,13 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), user_name = dirname + 1; else { - char *newp; - if (glob_use_alloca (alloca_used, end_name - dirname)) - newp = alloca_account (end_name - dirname, alloca_used); - else + char *newp = malloc (end_name - dirname); + if (newp == NULL) { - newp = malloc (end_name - dirname); - if (newp == NULL) - { - retval = GLOB_NOSPACE; - goto out; - } - malloc_user_name = 1; + retval = GLOB_NOSPACE; + goto out; } + malloc_user_name = 1; if (unescape != NULL) { char *p = mempcpy (newp, dirname + 1,