]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver: check for nullptr condition in regcache::get_register_status
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Tue, 17 Dec 2024 07:48:03 +0000 (08:48 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Tue, 17 Dec 2024 07:48:03 +0000 (08:48 +0100)
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>
gdbserver/regcache.cc

index 583b5624333a18fab2b9ccc292e78b067687f17f..4a064f6374b588d7f9bbde5595671b57f613eb97 100644 (file)
@@ -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