Don't pass NULL to memcpy in gdb
authorTom Tromey <tromey@adacore.com>
Tue, 31 Mar 2020 13:29:53 +0000 (07:29 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 31 Mar 2020 13:29:53 +0000 (07:29 -0600)
commitaf62665e1339d970ab8ea3e3260dbdbde0009c2d
tree826edde9a32cce686cb46b1a89f7a341034a7d4b
parent16b0db75af6b4b4d434aa84c74d58b7290e04143
Don't pass NULL to memcpy in gdb

I compiled gdb with -fsanitize=undefined and ran the test suite.

A couple of reports came from passing NULL to memcpy, e.g.:

[...]btrace-common.cc:176:13: runtime error: null pointer passed as argument 2, which is declared to never be null

While it would be better to fix this in the standard, in the meantime
it seems easy to avoid this error.

gdb/ChangeLog
2020-03-31  Tom Tromey  <tromey@adacore.com>

* dwarf2/abbrev.c (abbrev_table::read): Conditionally call
memcpy.

gdbsupport/ChangeLog
2020-03-31  Tom Tromey  <tromey@adacore.com>

* btrace-common.cc (btrace_data_append): Conditionally call
memcpy.
gdb/ChangeLog
gdb/dwarf2/abbrev.c
gdbsupport/ChangeLog
gdbsupport/btrace-common.cc