From 0b3effab72f5434b3bcb13fbc6b4ccdf784428d2 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Sun, 7 Mar 2021 07:03:29 +0900 Subject: Set GC_oom_fn in fuzzing --- fuzz/fuzz-conv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'fuzz') diff --git a/fuzz/fuzz-conv.c b/fuzz/fuzz-conv.c index b067378..3e85f86 100644 --- a/fuzz/fuzz-conv.c +++ b/fuzz/fuzz-conv.c @@ -14,11 +14,21 @@ char *get_null_terminated(const uint8_t *data, size_t size) { return new_str; } +static void *die_oom(size_t bytes) { + fprintf(stderr, "Out of memory: %lu bytes unavailable!\n", (unsigned long)bytes); + exit(1); +} + int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){ static int init_done = 0; if (!init_done) { GC_INIT(); +#if (GC_VERSION_MAJOR>7) || ((GC_VERSION_MAJOR==7) && (GC_VERSION_MINOR>=2)) + GC_set_oom_fn(die_oom); +#else + GC_oom_fn = die_oom; +#endif init_done = 1; } -- cgit v1.2.3