This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix undefined behavior, don't pass NULL to fwrite
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Fri, 05 Oct 2018 13:22:10 -0400
- Subject: [binutils-gdb] Fix undefined behavior, don't pass NULL to fwrite
*** TEST RESULTS FOR COMMIT 1f88d0c87c37d3a15fa6376335e8b0d1c79d85aa ***
Author: Simon Marchi <simon.marchi@ericsson.com>
Branch: master
Commit: 1f88d0c87c37d3a15fa6376335e8b0d1c79d85aa
Fix undefined behavior, don't pass NULL to fwrite
If a vector that we try to write using file_write is empty, we may end
up passing NULL to fwrite, which triggers UBSan:
.../gdb/dwarf-index-write.c:73:14: runtime error: null pointer passed as argument 1, which is declared to never be null
Avoid it by skipping the write if the vector is empty.
gdb/ChangeLog:
* dwarf-index-write.c (file_write): Don't write if the vector is
empty.