CMake: Add empty lines
[xz/debian.git] / tests / ossfuzz / fuzz_decode_alone.c
blob1ef2f9e7a6d909cec9a994819c4b3495b517f306
1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 /// \file fuzz_decode_alone.c
6 /// \brief Fuzz test program for liblzma .lzma decoding
7 //
8 // Authors: Maksym Vatsyk
9 // Lasse Collin
11 ///////////////////////////////////////////////////////////////////////////////
13 #include <inttypes.h>
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include "lzma.h"
17 #include "fuzz_common.h"
20 extern int
21 LLVMFuzzerTestOneInput(const uint8_t *inbuf, size_t inbuf_size)
23 lzma_stream strm = LZMA_STREAM_INIT;
24 // Initialize a LZMA alone decoder using the memory usage limit
25 // defined in fuzz_common.h
26 lzma_ret ret = lzma_alone_decoder(&strm, MEM_LIMIT);
28 if (ret != LZMA_OK) {
29 // This should never happen unless the system has
30 // no free memory or address space to allow the small
31 // allocations that the initialization requires.
32 fprintf(stderr, "lzma_alone_decoder() failed (%d)\n", ret);
33 abort();
36 fuzz_code(&strm, inbuf, inbuf_size);
38 // Free the allocated memory.
39 lzma_end(&strm);
40 return 0;