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 <collin.funk1@gmail.com>
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,