[PATCH] D15098: Libfuzzer: do not pass null into user function

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 17:46:19 PST 2015


kcc added inline comments.

================
Comment at: lib/Fuzzer/FuzzerLoop.cpp:242
@@ +241,3 @@
+  const uint8_t *Data = U.data();
+  static uint8_t EmptyData;
+  if (!Data) {
----------------
Looks weird. 
I would prefer to have assert(!U.empty()) and enforce it in callers. 

================
Comment at: lib/Fuzzer/test/SimpleTest.cpp:11
@@ -9,2 +10,3 @@
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+  assert(Data);
   if (Size > 0 && Data[0] == 'H') {
----------------
krasin wrote:
> Alternatively, you could #include "gtest/gtest.h" and use EXPECT_NE:
> 
> ```
> EXPECT_NE(NULL, Data) << "Pointer to the data must not be NULL"
> ```
> 
> EXPECT_NE will work even if LLVM is built without asserts, while assert will just pass.
Oh no, we don't want these simple tests to depend on gtest. 


http://reviews.llvm.org/D15098





More information about the llvm-commits mailing list