* src/utils.c (unique_name_1): Replace alloca by xmalloc

This commit is contained in:
Tim Rühsen 2020-02-13 11:48:06 +01:00
parent 233f982f9d
commit 4dd9dee2e7

View File

@ -659,7 +659,7 @@ unique_name_1 (const char *prefix)
{ {
int count = 1; int count = 1;
int plen = strlen (prefix); int plen = strlen (prefix);
char *template = (char *)alloca (plen + 1 + 24); char *template = xmalloc (plen + 1 + 24);
char *template_tail = template + plen; char *template_tail = template + plen;
memcpy (template, prefix, plen); memcpy (template, prefix, plen);
@ -667,9 +667,9 @@ unique_name_1 (const char *prefix)
do do
number_to_string (template_tail, count++); number_to_string (template_tail, count++);
while (file_exists_p (template, NULL)); while (file_exists_p (template, NULL) && count < 999999);
return xstrdup (template); return template;
} }
/* Return a unique file name, based on FILE. /* Return a unique file name, based on FILE.