aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-name-parser.y
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2024-04-17 16:17:33 -0600
committerTom Tromey <tom@tromey.com>2024-04-21 12:12:43 -0600
commite6375bc8ebbbc177c79f08e9616eb0b131229f65 (patch)
treefca4ad6a0389268a24e79e5b007b65528cda648d /gdb/cp-name-parser.y
parent7e9ef24e4a72d8d174932c7dd6be44226328ab88 (diff)
downloadbinutils-e6375bc8ebbbc177c79f08e9616eb0b131229f65.zip
binutils-e6375bc8ebbbc177c79f08e9616eb0b131229f65.tar.gz
binutils-e6375bc8ebbbc177c79f08e9616eb0b131229f65.tar.bz2
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 <jhb@FreeBSD.org>
Diffstat (limited to 'gdb/cp-name-parser.y')
-rw-r--r--gdb/cp-name-parser.y4
1 files changed, 0 insertions, 4 deletions
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;
}