aboutsummaryrefslogtreecommitdiffhomepage
path: root/fuzz/Fuzz.h
diff options
context:
space:
mode:
authorGravatar kjlubick <kjlubick@google.com>2016-10-24 11:53:35 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-24 11:53:35 -0700
commit85d301745a9031b13f1b716f07e1041f2fdd1ce3 (patch)
treeb527a7b348092df53343697a5b33a65ce4d59559 /fuzz/Fuzz.h
parentdf303a6f59a2121c133738d6304d2476689a4fd9 (diff)
Fix fuzzer's bools to be 0 or 1 only
Diffstat (limited to 'fuzz/Fuzz.h')
-rw-r--r--fuzz/Fuzz.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/fuzz/Fuzz.h b/fuzz/Fuzz.h
index 0ab3c1bc6e..c9c21567a5 100644
--- a/fuzz/Fuzz.h
+++ b/fuzz/Fuzz.h
@@ -24,6 +24,18 @@ public:
template <typename T>
bool next(T* n);
+ // UBSAN reminds us that bool can only legally hold 0 or 1.
+ bool next(bool* b) {
+ uint8_t byte;
+ if (!this->next(&byte)) {
+ return false;
+ }
+ *b = (byte & 1) == 1;
+ return true;
+ }
+
+ // The nextFoo methods are deprecated.
+ // TODO(kjlubick): replace existing uses with next() and remove these.
bool nextBool();
uint8_t nextB();
uint32_t nextU();