2019-06-25 16:22:02 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "lz4.h"
|
|
|
|
|
2019-06-28 19:54:46 +00:00
|
|
|
#define CHECK(COND) if (!(COND)) { abort(); }
|
|
|
|
|
2019-06-25 16:22:02 +00:00
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
|
|
{
|
|
|
|
size_t const compressed_dest_size = LZ4_compressBound(size);
|
|
|
|
char *const dest_buffer = (char *)malloc(compressed_dest_size);
|
|
|
|
|
2019-06-28 19:54:46 +00:00
|
|
|
if (dest_buffer != NULL)
|
2019-06-25 16:22:02 +00:00
|
|
|
{
|
2019-06-28 19:54:46 +00:00
|
|
|
// Allocation succeeded, try compressing the incoming data.
|
|
|
|
int result = LZ4_compress_default((const char*)data,
|
|
|
|
dest_buffer,
|
|
|
|
size,
|
|
|
|
compressed_dest_size);
|
|
|
|
CHECK(result != 0);
|
2019-06-25 16:22:02 +00:00
|
|
|
|
2019-06-28 19:54:46 +00:00
|
|
|
free(dest_buffer);
|
|
|
|
}
|
2019-06-25 16:22:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|