From ada4fe4aa8f88300cfc0dbe6ee965975274b1c40 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Tue, 6 Dec 2022 17:41:58 +0100 Subject: fuzz: add a new fuzzer testing memory allocation failures (#1818) Try to fuzz error paths triggered by allocation errors. Fix some errors already found by this new fuzzer. Basic idea taken from: https://github.com/harfbuzz/harfbuzz/pull/2566/files `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` is a standard define used to (not)compile specific code in fuzzing builds. See: https://llvm.org/docs/LibFuzzer.html --- src/lib/ndpi_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib/ndpi_utils.c') diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index ee6f076ab..b0922acd7 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -131,8 +131,9 @@ void * ndpi_tsearch(const void *vkey, void **vrootp, *rootp = q; /* link new node to old */ q->key = key; /* initialize new node */ q->left = q->right = (ndpi_node *)0; + return ((void *)q->key); } - return ((void *)q->key); + return ((void *)0); } /* ****************************************** */ -- cgit v1.2.3