From 4d1eaace8cc1166f82b867f61650f25f32018919 Mon Sep 17 00:00:00 2001
From: Niels Lohmann <mail@nlohmann.me>
Date: Wed, 24 Oct 2018 18:55:08 +0200
Subject: [PATCH] :hammer: fixed fuzz code to avoid false positives in case of
 discarded values

---
 test/src/fuzzer-parse_bson.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test/src/fuzzer-parse_bson.cpp b/test/src/fuzzer-parse_bson.cpp
index 4ba20dff..1d933767 100644
--- a/test/src/fuzzer-parse_bson.cpp
+++ b/test/src/fuzzer-parse_bson.cpp
@@ -33,6 +33,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
         std::vector<uint8_t> vec1(data, data + size);
         json j1 = json::from_bson(vec1);
 
+        if (j1.is_discarded())
+        {
+            return 0;
+        }
+
         try
         {
             // step 2: round trip