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.
This commit is contained in:
parent
fb9bbfd7f2
commit
10657c047e
2 changed files with 7 additions and 2 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue