diff options
author | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2024-12-17 08:48:03 +0100 |
---|---|---|
committer | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2024-12-17 08:48:03 +0100 |
commit | 81b65d86956f1f47cf7d45cd58d9ca849fe8ffc6 (patch) | |
tree | 943f5fda9c048cefa7a30f781471ed74c66cf56b | |
parent | ccdddcac51d41d4c2adaf79d5db4d0eefa5a682b (diff) | |
download | binutils-81b65d86956f1f47cf7d45cd58d9ca849fe8ffc6.zip binutils-81b65d86956f1f47cf7d45cd58d9ca849fe8ffc6.tar.gz binutils-81b65d86956f1f47cf7d45cd58d9ca849fe8ffc6.tar.bz2 |
gdbserver: check for nullptr condition in regcache::get_register_status
A regcache can be initialized with a register value buffer, in which
case, the register_status pointer is null. This condition is checked
in set_register_status, but not in get_register_status. Do this check
for consistence and safety.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r-- | gdbserver/regcache.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 583b562..4a064f6 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -526,7 +526,10 @@ regcache::get_register_status (int regnum) const { #ifndef IN_PROCESS_AGENT gdb_assert (regnum >= 0 && regnum < tdesc->reg_defs.size ()); - return (enum register_status) (register_status[regnum]); + if (register_status != nullptr) + return (enum register_status) (register_status[regnum]); + else + return REG_VALID; #else return REG_VALID; #endif |