summaryrefslogtreecommitdiffstats
path: root/tools/fuzzing/libfuzzer/patches/10-ef-runtime.patch
blob: a544f42bd75d24050da9fd178840641c166b0526 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# HG changeset patch
# User Christian Holler <choller@mozilla.com>
# Date 1596126054 -7200
#      Thu Jul 30 18:20:54 2020 +0200
# Node ID 8a2a26b33d516c43c366b2f24d731d27d9843349
# Parent  997c4109edd112695097fd8c55cbacd976cab24a
[libFuzzer] Allow external functions to be defined at runtime

diff --git a/FuzzerDriver.cpp b/FuzzerDriver.cpp
--- a/FuzzerDriver.cpp
+++ b/FuzzerDriver.cpp
@@ -608,17 +608,18 @@ static Vector<SizedFile> ReadCorpora(con
       SizedFiles.push_back({File, Size});
   return SizedFiles;
 }
 
 int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
   using namespace fuzzer;
   assert(argc && argv && "Argument pointers cannot be nullptr");
   std::string Argv0((*argv)[0]);
-  EF = new ExternalFunctions();
+  if (!EF)
+    EF = new ExternalFunctions();
   if (EF->LLVMFuzzerInitialize)
     EF->LLVMFuzzerInitialize(argc, argv);
   if (EF->__msan_scoped_disable_interceptor_checks)
     EF->__msan_scoped_disable_interceptor_checks();
   const Vector<std::string> Args(*argv, *argv + *argc);
   assert(!Args.empty());
   ProgName = new std::string(Args[0]);
   if (Argv0 != *ProgName) {