From 5505aced03322eed54888b511e85ec65366fc24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Thu, 13 Feb 2020 17:01:29 +0100 Subject: [PATCH] * src/html-parse.c (name_allowed): Remove use of alloca --- src/html-parse.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/html-parse.c b/src/html-parse.c index 30c8ae8e..63677324 100644 --- a/src/html-parse.c +++ b/src/html-parse.c @@ -777,11 +777,27 @@ find_comment_end (const char *beg, const char *end) static bool name_allowed (const struct hash_table *ht, const char *b, const char *e) { - char *copy; + char buf[256], *copy; + size_t len = e - b; + bool ret; + if (!ht) return true; - BOUNDED_TO_ALLOCA (b, e, copy); - return hash_table_get (ht, copy) != NULL; + + if (len < sizeof (buf)) + copy = buf; + else + copy = xmalloc (len + 1); + + memcpy (copy, b, len); + copy[len] = 0; + + ret = hash_table_get (ht, copy) != NULL; + + if (copy != buf) + xfree (copy); + + return ret; } /* Advance P (a char pointer), with the explicit intent of being able