aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2022-04-12 14:37:24 -0400
committerSimon Marchi <simon.marchi@efficios.com>2022-04-12 14:42:02 -0400
commita8b7a1391135b63de73c1bf0e0a2f8f5dc8c6ba6 (patch)
tree0e05a83bb5cf746a6ab21ffdf5f680810678d285 /gdb/c-lang.c
parent558802e4d1c5dcbd0df7d2c6ef62a6deac247a2f (diff)
downloadgdb-a8b7a1391135b63de73c1bf0e0a2f8f5dc8c6ba6.zip
gdb-a8b7a1391135b63de73c1bf0e0a2f8f5dc8c6ba6.tar.gz
gdb-a8b7a1391135b63de73c1bf0e0a2f8f5dc8c6ba6.tar.bz2
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
Diffstat (limited to 'gdb/c-lang.c')
0 files changed, 0 insertions, 0 deletions