[llvm] r292575 - BitVector: Fix undefined behaviour
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 19 20:23:08 PST 2017
Author: matze
Date: Thu Jan 19 22:23:08 2017
New Revision: 292575
URL: http://llvm.org/viewvc/llvm-project?rev=292575&view=rev
Log:
BitVector: Fix undefined behaviour
Calling reset() on an empty BitVector would call memset with a nullptr
argument which is undefined behaviour.
This should fix the sanitizer bot.
Modified:
llvm/trunk/include/llvm/ADT/BitVector.h
Modified: llvm/trunk/include/llvm/ADT/BitVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/BitVector.h?rev=292575&r1=292574&r2=292575&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/BitVector.h (original)
+++ llvm/trunk/include/llvm/ADT/BitVector.h Thu Jan 19 22:23:08 2017
@@ -539,7 +539,8 @@ private:
}
void init_words(BitWord *B, unsigned NumWords, bool t) {
- memset(B, 0 - (int)t, NumWords*sizeof(BitWord));
+ if (NumWords > 0)
+ memset(B, 0 - (int)t, NumWords*sizeof(BitWord));
}
template<bool AddBits, bool InvertMask>
More information about the llvm-commits
mailing list