aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2019-08-06 18:39:20 -0700
committerPaul Eggert2019-08-06 18:39:58 -0700
commit220f16cab6c40a1b0df1a5d2101c6602abbc6aae (patch)
tree7869f939e211266640238e249700c8dad6ed8c09 /src
parentd9d58555d9de034ed78c61b054ef4c127dfad289 (diff)
downloademacs-220f16cab6c40a1b0df1a5d2101c6602abbc6aae.tar.gz
emacs-220f16cab6c40a1b0df1a5d2101c6602abbc6aae.zip
Re-port dump_bitset_clear to -fsanitize=undefined
* src/pdumper.c (dump_bitset_clear): Skip the memset if the size is zero, because in that case the destination might be NULL. This fixes a bug introduced in 2019-07-26T06:17:52Zeggert@cs.ucla.edu. Add a comment to make the bug less likely to reoccur.
Diffstat (limited to 'src')
-rw-r--r--src/pdumper.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pdumper.c b/src/pdumper.c
index e0ddc1c8088..326a346a632 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -4931,7 +4931,10 @@ dump_bitset_set_bit (struct dump_bitset *bitset, size_t bit_number)
4931static void 4931static void
4932dump_bitset_clear (struct dump_bitset *bitset) 4932dump_bitset_clear (struct dump_bitset *bitset)
4933{ 4933{
4934 memset (bitset->bits, 0, bitset->number_words * sizeof bitset->bits[0]); 4934 /* Skip the memset if bitset->number_words == 0, because then bitset->bits
4935 might be NULL and the memset would have undefined behavior. */
4936 if (bitset->number_words)
4937 memset (bitset->bits, 0, bitset->number_words * sizeof bitset->bits[0]);
4935} 4938}
4936 4939
4937struct pdumper_loaded_dump_private 4940struct pdumper_loaded_dump_private