public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Farre <simon.farre.cx@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2] Fix dereference of possible nullptr in -O3
Date: Tue, 10 May 2022 19:22:46 +0200	[thread overview]
Message-ID: <20220510172246.920520-1-simon.farre.cx@gmail.com> (raw)

v2. Formatting.

v1: Building with full optimizations (-O3) complains that this might
be a nullptr. If this is never null, perhaps the parameter
should be changed to a reference, but that would change the interface.
---
 gdb/regcache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/regcache.c b/gdb/regcache.c
index a5e83da1ca4..20a4ddcd52a 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1173,7 +1173,8 @@ regcache::transfer_regset_register (struct regcache *out_regcache, int regnum,
   else
     {
       /* Invalidate the register.  */
-      out_regcache->raw_supply (regnum, nullptr);
+      if (out_regcache != nullptr)
+	out_regcache->raw_supply (regnum, nullptr);
     }
 }
 

base-commit: 16089f320a9226e7cdb73e9fb4266d9e450085b2
-- 
2.34.1


             reply	other threads:[~2022-05-10 17:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 17:22 Simon Farre [this message]
2022-05-11 11:55 ` Pedro Alves
2022-05-11 14:57   ` Simon Farre

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=20220510172246.920520-1-simon.farre.cx@gmail.com \
    --to=simon.farre.cx@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).