From 4dd9dee2e79c2ca6f277011b399e163c19273ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Thu, 13 Feb 2020 11:48:06 +0100 Subject: [PATCH] * src/utils.c (unique_name_1): Replace alloca by xmalloc --- src/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.c b/src/utils.c index 9d78cadb..75eada17 100644 --- a/src/utils.c +++ b/src/utils.c @@ -659,7 +659,7 @@ unique_name_1 (const char *prefix) { int count = 1; int plen = strlen (prefix); - char *template = (char *)alloca (plen + 1 + 24); + char *template = xmalloc (plen + 1 + 24); char *template_tail = template + plen; memcpy (template, prefix, plen); @@ -667,9 +667,9 @@ unique_name_1 (const char *prefix) do 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.