aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-08-18 07:55:30 -0600
committerTom Tromey <tromey@adacore.com>2023-08-18 13:03:23 -0600
commit28bb48114db4de4ba0a72940af1c30728b6e82f2 (patch)
treebf9575a160fd24478332921ed20dff7fc3aa1e65
parentb7cadd86197e55698db85441b2792ca330a71a75 (diff)
downloadbinutils-28bb48114db4de4ba0a72940af1c30728b6e82f2.zip
binutils-28bb48114db4de4ba0a72940af1c30728b6e82f2.tar.gz
binutils-28bb48114db4de4ba0a72940af1c30728b6e82f2.tar.bz2
Fix off-by-one in call to vector::reserve
While looking at a bug, I noticed what I think is an off-by-one mistake in a call to vector::reserve. This code: new_args.reserve (args.size ()); new_args.push_back (value_from_pointer (lookup_pointer_type (values_type), struct_addr)); new_args.insert (new_args.end (), args.begin (), args.end ()); ... reserves 'size()' entries, but then proceeds to push one extra one. This shouldn't have any really bad effects, as insert will grow the vector. Still, it seems better to use the correct size if we're going to bother calling reserve. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30780 Reviewed-by: John Baldwin <jhb@FreeBSD.org>
-rw-r--r--gdb/infcall.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/infcall.c b/gdb/infcall.c
index bea5b18..41ed3ed 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -1233,7 +1233,7 @@ call_function_by_hand_dummy (struct value *function,
if (return_method == return_method_hidden_param)
{
/* Add the new argument to the front of the argument list. */
- new_args.reserve (args.size ());
+ new_args.reserve (1 + args.size ());
new_args.push_back
(value_from_pointer (lookup_pointer_type (values_type), struct_addr));
new_args.insert (new_args.end (), args.begin (), args.end ());