mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 05:27:23 +00:00
24 lines
555 B
C
24 lines
555 B
C
// clang -g -O1 -fsanitize=fuzzer -o fuzz fuzz.c
|
|
#include "quickjs.h"
|
|
#include "quickjs.c"
|
|
#include "cutils.c"
|
|
#include "libbf.c"
|
|
#include "libregexp.c"
|
|
#include "libunicode.c"
|
|
#include <stdlib.h>
|
|
|
|
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
|
{
|
|
JSRuntime *rt = JS_NewRuntime();
|
|
if (!rt)
|
|
exit(1);
|
|
JSContext *ctx = JS_NewContext(rt);
|
|
if (!ctx)
|
|
exit(1);
|
|
JSValueConst val = JS_ReadObject(ctx, buf, len, /*flags*/0);
|
|
JS_FreeValue(ctx, val);
|
|
JS_FreeContext(ctx);
|
|
JS_FreeRuntime(rt);
|
|
return 0;
|
|
}
|