binutils-gdb/gdb/dwarf2
Simon Marchi a8b7a13911 gdb: fix "passing NULL to memcpy" UBsan error in dwarf2/cooked-index.c
Reading a simple file compiled with :

    $ gcc -DONE=1 -gdwarf-4 -g3  test.c
    $ gcc --version
    gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0

I get:

    Reading symbols from /tmp/cwd/a.out...
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/cooked-index.c:332:11: runtime error: null pointer passed as argument 2, which is declared to never be null

It looks like even if the size is 0 (the size of the `entries` vector is
0), we shouldn't be passing a NULL pointer to memcpy.  And
`entries.data ()` returns NULL.

Fix that by using std::vector::insert to insert the items of entries
into m_entries.  I haven't checked, but it should essentially compile
down to a memcpy, since the vector elements are trivially copyiable.

Change-Id: I75f1c901e9b522e42e89eb5936e2c70d68eb21e5
2022-04-12 14:42:02 -04:00
..
abbrev-cache.c Introduce DWARF abbrev cache 2022-04-12 09:31:16 -06:00
abbrev-cache.h Introduce DWARF abbrev cache 2022-04-12 09:31:16 -06:00
abbrev.c Statically examine abbrev properties 2022-04-12 09:31:16 -06:00
abbrev.h Statically examine abbrev properties 2022-04-12 09:31:16 -06:00
attribute.c
attribute.h
comp-unit-head.c
comp-unit-head.h
cooked-index.c gdb: fix "passing NULL to memcpy" UBsan error in dwarf2/cooked-index.c 2022-04-12 14:42:02 -04:00
cooked-index.h "Finalize" the DWARF index in the background 2022-04-12 09:31:16 -06:00
cu.c Delete DWARF psymtab code 2022-04-12 09:31:17 -06:00
cu.h
die.h
dwz.c
dwz.h
expr.c
expr.h
file-and-dir.h Add "fullname" handling to file_and_directory 2022-04-12 09:31:16 -06:00
frame-tailcall.c
frame-tailcall.h
frame.c
frame.h
index-cache.c Rename write_psymtabs_to_index 2022-04-12 09:31:16 -06:00
index-cache.h
index-common.c Add new overload of dwarf5_djb_hash 2022-04-12 09:31:16 -06:00
index-common.h Add new overload of dwarf5_djb_hash 2022-04-12 09:31:16 -06:00
index-write.c Delete DWARF psymtab code 2022-04-12 09:31:17 -06:00
index-write.h Rename write_psymtabs_to_index 2022-04-12 09:31:16 -06:00
leb.c
leb.h
line-header.c gdb: change file_file_name to return an std::string 2022-04-07 20:31:31 -04:00
line-header.h Delete DWARF psymtab code 2022-04-12 09:31:17 -06:00
loc.c gdb: remove symbol value macros 2022-04-11 10:45:36 -04:00
loc.h
macro.c gdb: change file_file_name to return an std::string 2022-04-07 20:31:31 -04:00
macro.h
public.h Delete DWARF psymtab code 2022-04-12 09:31:17 -06:00
read.c gdb: change subfile::name and buildsym_compunit::m_comp_dir to strings 2022-04-12 14:13:10 -04:00
read.h Remove dwarf2_per_cu_data::v 2022-04-12 09:31:17 -06:00
sect-names.h
section.c
section.h
stringify.c
stringify.h