[PATCH] Fix dereference of possible nullptr in -O3
Bruno Larsen
blarsen@redhat.com
Tue May 10 14:17:37 GMT 2022
On 5/10/22 11:09, Simon Farre via Gdb-patches wrote:
> 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.
Thanks for looking at this!
> ---
> gdb/regcache.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/regcache.c b/gdb/regcache.c
> index a5e83da1ca4..9cf0fbcf91c 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)
The GDB coding style says that this should be
if (out_regcache == nullptr)
> + out_regcache->raw_supply (regnum, nullptr);
> }
> }
>
>
> base-commit: 16089f320a9226e7cdb73e9fb4266d9e450085b2
Cheers!
Bruno Larsen
More information about the Gdb-patches
mailing list