From e6375bc8ebbbc177c79f08e9616eb0b131229f65 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 17 Apr 2024 16:17:33 -0600 Subject: Remove some alloca uses A few spots (mostly in the parsers) use alloca to ensure that a string is terminated before passing it to a printf-like function (mostly 'error'). However, this isn't needed as the "%.*s" format can be used instead. This patch makes this change. In one spot the alloca is dead code and is simply removed. Regression tested on x86-64 Fedora 38. Approved-By: John Baldwin --- gdb/cp-name-parser.y | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gdb/cp-name-parser.y') diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 87f1344..e944276 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -1702,10 +1702,6 @@ yylex (YYSTYPE *lvalp, cpname_state *state) lvalp); if (toktype == ERROR) { - char *err_copy = (char *) alloca (p - tokstart + 1); - - memcpy (err_copy, tokstart, p - tokstart); - err_copy[p - tokstart] = 0; yyerror (state, _("invalid number")); return ERROR; } -- cgit v1.1