tomato-testing/qoifuzz.c
Green Sky 3678301916 Squashed 'external/qoi/qoi/' content from commit 30d15d79b7
git-subtree-dir: external/qoi/qoi
git-subtree-split: 30d15d79b7726b977cd889151cc5cd6b17742f8f
2024-03-06 01:04:41 +01:00

33 lines
579 B
C

/*
Copyright (c) 2021, Dominic Szablewski - https://phoboslab.org
SPDX-License-Identifier: MIT
clang fuzzing harness for qoi_decode
Compile and run with:
clang -fsanitize=address,fuzzer -g -O0 qoifuzz.c && ./a.out
*/
#define QOI_IMPLEMENTATION
#include "qoi.h"
#include <stddef.h>
#include <stdint.h>
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
int w, h;
if (size < 4) {
return 0;
}
qoi_desc desc;
void* decoded = qoi_decode((void*)(data + 4), (int)(size - 4), &desc, *((int *)data));
if (decoded != NULL) {
free(decoded);
}
return 0;
}