diff options
author | Tom Tromey <tom@tromey.com> | 2018-07-26 17:48:40 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-10-03 15:19:06 -0600 |
commit | 10657c047e4e0257440c80fda5f4e23a3452616c (patch) | |
tree | 68d91988f0db35427f735036697378d5793e689f /gdb | |
parent | fb9bbfd7f2d39a1d4850fcf0f63ef1f077f55e4b (diff) | |
download | gdb-10657c047e4e0257440c80fda5f4e23a3452616c.zip gdb-10657c047e4e0257440c80fda5f4e23a3452616c.tar.gz gdb-10657c047e4e0257440c80fda5f4e23a3452616c.tar.bz2 |
Do not pass NULL to memcpy
-fsanitize=undefined pointed out a spot that passes NULL to memcpy,
which is undefined behavior according to the C standard.
gdb/ChangeLog
2018-10-03 Tom Tromey <tom@tromey.com>
* namespace.c (add_using_directive): Don't pass NULL to memcpy.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/namespace.c | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f5448c3..1f8b8e5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2018-10-03 Tom Tromey <tom@tromey.com> + + * namespace.c (add_using_directive): Don't pass NULL to memcpy. + 2018-10-03 Philippe Waroquiers <philippe.waroquiers@skynet.be> * tid-parse.c (tid_is_in_list): Fix wrong 'See' comment. diff --git a/gdb/namespace.c b/gdb/namespace.c index be998d9..85c0c4b 100644 --- a/gdb/namespace.c +++ b/gdb/namespace.c @@ -111,8 +111,9 @@ add_using_directive (struct using_direct **using_directives, else newobj->declaration = declaration; - memcpy (newobj->excludes, excludes.data (), - excludes.size () * sizeof (*newobj->excludes)); + if (!excludes.empty ()) + memcpy (newobj->excludes, excludes.data (), + excludes.size () * sizeof (*newobj->excludes)); newobj->excludes[excludes.size ()] = NULL; newobj->next = *using_directives; |