From b1da98a74656685087b0afd97af8080edc78d995 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 24 Jul 2024 15:07:15 -0400 Subject: [PATCH] gdb: remove use of alloca in new_macro_definition Replace alloca with std::vector. Change-Id: Ie8756da09126f6808e5b52c43388ad9324e8ad2c Approved-By: Tom de Vries --- gdb/macrotab.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gdb/macrotab.c b/gdb/macrotab.c index 81fe1657673..21ec1522a90 100644 --- a/gdb/macrotab.c +++ b/gdb/macrotab.c @@ -564,15 +564,14 @@ new_macro_definition (macro_table *t, macro_kind kind, d->argc = argv.size (); /* Bcache all the arguments. */ - int i = 0; - int cached_argv_size = argv.size () * sizeof (const char *); - const char **cached_argv = (const char **) alloca (cached_argv_size); + std::vector cached_argv; for (const auto &arg : argv) - cached_argv[i++] = macro_bcache_str (t, arg.c_str ()); + cached_argv.push_back (macro_bcache_str (t, arg.c_str ())); /* Now bcache the array of argument pointers itself. */ - d->argv = macro_bcache (t, cached_argv, cached_argv_size); + d->argv = macro_bcache (t, cached_argv.data (), + cached_argv.size () * sizeof (const char *)); } else d->argc = special_kind;