Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: fuzz/Fuzz.h

Issue 2447823002: Fix fuzzer's bools to be 0 or 1 only (Closed)
Patch Set: Line up Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | fuzz/FuzzGradients.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fuzz/Fuzz.h
diff --git a/fuzz/Fuzz.h b/fuzz/Fuzz.h
index 0ab3c1bc6e313c9cc3bd91c0d2c48f4af3078252..c9c21567a557238782c52955397b0cf4de974bed 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();
« no previous file with comments | « no previous file | fuzz/FuzzGradients.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698