[PUSHED 4/8] gdbserver: check for nullptr condition in regcache::get_register_status
Tankut Baris Aktemur
tankut.baris.aktemur@intel.com
Tue Dec 17 08:18:26 GMT 2024
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 | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 583b5624333..4a064f6374b 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
--
2.34.1
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
More information about the Gdb-patches
mailing list