public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Fix dereference of possible nullptr in -O3
@ 2022-05-10 17:22 Simon Farre
  2022-05-11 11:55 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Farre @ 2022-05-10 17:22 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-11 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 17:22 [PATCH v2] Fix dereference of possible nullptr in -O3 Simon Farre
2022-05-11 11:55 ` Pedro Alves
2022-05-11 14:57   ` Simon Farre

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).