diff options
author | Tom Tromey <tom@tromey.com> | 2024-04-17 16:17:33 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-04-21 12:12:43 -0600 |
commit | e6375bc8ebbbc177c79f08e9616eb0b131229f65 (patch) | |
tree | fca4ad6a0389268a24e79e5b007b65528cda648d /gdb/m2-exp.y | |
parent | 7e9ef24e4a72d8d174932c7dd6be44226328ab88 (diff) | |
download | gdb-e6375bc8ebbbc177c79f08e9616eb0b131229f65.zip gdb-e6375bc8ebbbc177c79f08e9616eb0b131229f65.tar.gz gdb-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/m2-exp.y')
-rw-r--r-- | gdb/m2-exp.y | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index ebbc49c..28005e1 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -869,13 +869,8 @@ yylex (void) } toktype = parse_number (p - tokstart); if (toktype == ERROR) - { - char *err_copy = (char *) alloca (p - tokstart + 1); - - memcpy (err_copy, tokstart, p - tokstart); - err_copy[p - tokstart] = 0; - error (_("Invalid number \"%s\"."), err_copy); - } + error (_("Invalid number \"%.*s\"."), (int) (p - tokstart), + tokstart); pstate->lexptr = p; return toktype; } |