From 85d301745a9031b13f1b716f07e1041f2fdd1ce3 Mon Sep 17 00:00:00 2001 From: kjlubick Date: Mon, 24 Oct 2016 11:53:35 -0700 Subject: 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 --- fuzz/Fuzz.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'fuzz/Fuzz.h') 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 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(); -- cgit v1.2.3