diff options
author | kjlubick <kjlubick@google.com> | 2016-10-24 11:53:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-24 11:53:35 -0700 |
commit | 85d301745a9031b13f1b716f07e1041f2fdd1ce3 (patch) | |
tree | b527a7b348092df53343697a5b33a65ce4d59559 /fuzz/Fuzz.h | |
parent | df303a6f59a2121c133738d6304d2476689a4fd9 (diff) |
Fix fuzzer's bools to be 0 or 1 only
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2447823002
Review-Url: https://codereview.chromium.org/2447823002
Diffstat (limited to 'fuzz/Fuzz.h')
-rw-r--r-- | fuzz/Fuzz.h | 12 |
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(); |