From 249374ada4b8f289a4fd02f50de46cbf28825e52 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Mon, 19 Jun 2023 22:11:34 +0200 Subject: [PATCH] fuzz: make target resist allocation failures So that fuzzing can go on with simulated allocation failures --- c/fuzz/decode_fuzzer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/c/fuzz/decode_fuzzer.c b/c/fuzz/decode_fuzzer.c index 46144e07e..697f9bf22 100644 --- a/c/fuzz/decode_fuzzer.c +++ b/c/fuzz/decode_fuzzer.c @@ -27,6 +27,11 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { size_t total_out = 0; BrotliDecoderState* state = BrotliDecoderCreateInstance(0, 0, 0); + if (!state) { + // OOM is out-of-scope here. + free(buffer); + return 0; + } if (addend == 0) addend = size;