summaryrefslogtreecommitdiff
path: root/gdb/h8300-tdep.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-10-04 20:47:06 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-10-25 14:51:44 -0400
commit50888e42dcd32b30e1144c0aa6d1c1490da45cd9 (patch)
tree72fad89d67057ecb53f26bac0464542829053e3e /gdb/h8300-tdep.c
parentd9f82e931394efed68858eb7c7bb5832ad888482 (diff)
downloadbinutils-gdb-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.tar.gz
gdb: change functions returning value contents to use gdb::array_view
The bug fixed by this [1] patch was caused by an out-of-bounds access to a value's content. The code gets the value's content (just a pointer) and then indexes it with a non-sensical index. This made me think of changing functions that return value contents to return array_views instead of a plain pointer. This has the advantage that when GDB is built with _GLIBCXX_DEBUG, accesses to the array_view are checked, making bugs more apparent / easier to find. This patch changes the return types of these functions, and updates callers to call .data() on the result, meaning it's not changing anything in practice. Additional work will be needed (which can be done little by little) to make callers propagate the use of array_view and reap the benefits. [1] https://sourceware.org/pipermail/gdb-patches/2021-September/182306.html Change-Id: I5151f888f169e1c36abe2cbc57620110673816f3
Diffstat (limited to 'gdb/h8300-tdep.c')
-rw-r--r--gdb/h8300-tdep.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 7d4495f6646..7a7da9d1031 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -648,7 +648,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
struct type *type = value_type (args[argument]);
int len = TYPE_LENGTH (type);
- char *contents = (char *) value_contents (args[argument]);
+ char *contents = (char *) value_contents (args[argument]).data ();
/* Pad the argument appropriately. */
int padded_len = align_up (len, wordsize);