From: Simon Marchi <simon.marchi@polymtl.ca>
To: Ruslan Kabatsayev <b7.10110111@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Avoid indexing std::vector past the end
Date: Sun, 31 Dec 2017 01:31:00 -0000 [thread overview]
Message-ID: <da06a1e9717b54683bc772074ac60a78@polymtl.ca> (raw)
In-Reply-To: <1514662273-27858-1-git-send-email-b7.10110111@gmail.com>
On 2017-12-30 14:31, Ruslan Kabatsayev wrote:
> The code here wants to find address of an element, and often this
> element is one past the end of std::vector. Dereferencing that element
> leads to undefined behavior, so it's better to simply use pointer
> arithmetic instead of taking address of invalid dereference.
>
> gdb/ChangeLog:
>
> * psymtab.c (recursively_search_psymtabs): Use pointer arithmetic
> instead of dereferencing std::vector past the end.
Hi Ruslan,
The patch LGTM, with a nit I missed the first time. Please push with
that fixed.
> ---
> gdb/psymtab.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/psymtab.c b/gdb/psymtab.c
> index c87ef25..c622f4c 100644
> --- a/gdb/psymtab.c
> +++ b/gdb/psymtab.c
> @@ -1337,21 +1337,21 @@ recursively_search_psymtabs
> }
>
> partial_symbol **gbound
> - = &objfile->global_psymbols[ps->globals_offset +
> ps->n_global_syms];
> + = objfile->global_psymbols.data() + ps->globals_offset +
> ps->n_global_syms;
Space before parentheses, here and in the other lines.
Thanks,
Simon
prev parent reply other threads:[~2017-12-31 1:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-30 19:31 Ruslan Kabatsayev
2017-12-31 1:31 ` Simon Marchi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da06a1e9717b54683bc772074ac60a78@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=b7.10110111@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).