aboutsummaryrefslogtreecommitdiffstats
path: root/fuzz/fuzz-conv.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2021-03-06 22:03:29 +0000
committerTatsuya Kinoshita <tats@debian.org>2021-03-06 22:03:29 +0000
commit0b3effab72f5434b3bcb13fbc6b4ccdf784428d2 (patch)
treea2a3a9f8c98074505faafee5d58b7c9ab5f6484c /fuzz/fuzz-conv.c
parentUpdate ChangeLog (diff)
downloadw3m-0b3effab72f5434b3bcb13fbc6b4ccdf784428d2.tar.gz
w3m-0b3effab72f5434b3bcb13fbc6b4ccdf784428d2.zip
Set GC_oom_fn in fuzzing
Diffstat (limited to 'fuzz/fuzz-conv.c')
-rw-r--r--fuzz/fuzz-conv.c10
1 files changed, 10 insertions, 0 deletions
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;
}