From e91e96ccb515b6e06b5c228a8dbea4b33e01edba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Thu, 13 Feb 2020 16:50:21 +0100 Subject: [PATCH] * src/init.c (parse_line): Remove use of alloca --- src/init.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/init.c b/src/init.c index 062564c2..ac2834e0 100644 --- a/src/init.c +++ b/src/init.c @@ -827,6 +827,8 @@ parse_line (const char *line, char **com, char **val, int *comind) const char *end = line + strlen (line); const char *cmdstart, *cmdend; const char *valstart, *valend; + char buf[1024]; + size_t len; char *cmdcopy; int ind; @@ -867,9 +869,18 @@ parse_line (const char *line, char **com, char **val, int *comind) /* The line now known to be syntactically correct. Check whether the command is valid. */ - BOUNDED_TO_ALLOCA (cmdstart, cmdend, cmdcopy); + len = cmdend - cmdstart; + if (len < sizeof (buf)) + cmdcopy = buf; + else + cmdcopy = xmalloc (len + 1); + memcpy (cmdcopy, cmdstart, len); + cmdcopy[len] = 0; + dehyphen (cmdcopy); ind = command_by_name (cmdcopy); + if (cmdcopy != buf) + xfree (cmdcopy); if (ind == -1) return line_unknown_command;