emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 220f16c: Re-port dump_bitset_clear to -fsanitize=un


From: Paul Eggert
Subject: [Emacs-diffs] master 220f16c: Re-port dump_bitset_clear to -fsanitize=undefined
Date: Tue, 6 Aug 2019 21:40:02 -0400 (EDT)

branch: master
commit 220f16cab6c40a1b0df1a5d2101c6602abbc6aae
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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:address@hidden.
    Add a comment to make the bug less likely to reoccur.
---
 src/pdumper.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/pdumper.c b/src/pdumper.c
index e0ddc1c..326a346 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)
 static void
 dump_bitset_clear (struct dump_bitset *bitset)
 {
-  memset (bitset->bits, 0, bitset->number_words * sizeof bitset->bits[0]);
+  /* Skip the memset if bitset->number_words == 0, because then bitset->bits
+     might be NULL and the memset would have undefined behavior.  */
+  if (bitset->number_words)
+    memset (bitset->bits, 0, bitset->number_words * sizeof bitset->bits[0]);
 }
 
 struct pdumper_loaded_dump_private



reply via email to

[Prev in Thread] Current Thread [Next in Thread]