2019-06-26 00:22:02 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "lz4.h"
|
|
|
|
|
2019-06-29 03:54:46 +08:00
|
|
|
#define CHECK(COND) if (!(COND)) { abort(); }
|
|
|
|
|
2019-06-29 06:48:33 +08:00
|
|
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
2019-06-26 00:22:02 +08:00
|
|
|
{
|
|
|
|
size_t const compressed_dest_size = LZ4_compressBound(size);
|
|
|
|
char *const dest_buffer = (char *)malloc(compressed_dest_size);
|
|
|
|
|
2019-06-29 07:23:06 +08:00
|
|
|
CHECK(dest_buffer != NULL);
|
2019-06-26 00:22:02 +08:00
|
|
|
|
2019-06-29 07:23:06 +08: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);
|
|
|
|
|
|
|
|
free(dest_buffer);
|
2019-06-26 00:22:02 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|