diff --git a/src/tools/ftfuzzer/ftfuzzer.cc b/src/tools/ftfuzzer/ftfuzzer.cc
index b33ed22..8040493 100644
--- a/src/tools/ftfuzzer/ftfuzzer.cc
+++ b/src/tools/ftfuzzer/ftfuzzer.cc
@@ -12,6 +12,20 @@
 // understand and accept it fully.
 
 
+// The following defines affect the behavior of fuzzing.
+// They are not enabled by default for performance reasons,
+// but can be very useful when tracking down issues.
+//
+// FT_FUZZER_FORCE_LOCAL_LIBRARY
+//   Forces a new FT_Library to be created for each input.
+//   By default a single FT_Library is used per process.
+//
+// FT_FUZZER_FORCE_LSAN_CHECK
+//   Forces LeakSanitizer checks to be done after processing each input.
+//   LeakSanitizer normally runs a leak check at process exit.
+//   Since libFuzzer is an in process fuzzer, leaks will not be reported until
+//   the end of a fuzzer run which can cause reproducing cases to be lost.
+
 // we use `unique_ptr', `decltype', and other gimmicks defined since C++11
 #if __cplusplus < 201103L
 #  error "a C++11 compiler is needed"
@@ -24,6 +38,7 @@
 #include <stdint.h>
 
 #include <memory>
+#include <type_traits>
 #include <vector>
 
 
@@ -47,21 +62,27 @@
 #include FT_TRUETYPE_DRIVER_H
 #include FT_MULTIPLE_MASTERS_H
 
-
-  static FT_Library  library;
-  static int         InitResult;
+  extern "C" {
+    int __lsan_do_recoverable_leak_check();
+  }
 
 
   struct FT_Global {
     FT_Global() {
-      InitResult = FT_Init_FreeType( &library );
+      int result = FT_Init_FreeType( &library );
+      assert( !result );
     }
     ~FT_Global() {
       FT_Done_FreeType( library );
     }
+    FT_Library get() {
+      return library;
+    }
+   private:
+    FT_Library  library;
   };
 
-  FT_Global  global_ft;
+  FT_Global  library;
 
 
   static int
@@ -166,13 +187,30 @@
       return;
   }
 
+  extern "C" {
+    static void* ft_memory_alloc( FT_Memory, long size ) {
+      return malloc(size);
+    }
+    static void ft_memory_free( FT_Memory, void* block ) {
+      free(block);
+    }
+    static void* ft_memory_realloc( FT_Memory, long cur_size, long new_size, void* block ) {
+      return realloc(block, new_size);
+    }
+  };
+  static const FT_MemoryRec_ gFTMemory = { nullptr, ft_memory_alloc, ft_memory_free, ft_memory_realloc };
 
-  // the interface function to the libFuzzer library
-  extern "C" int
-  LLVMFuzzerTestOneInput( const uint8_t*  data,
-                          size_t          size_ )
+  static int
+  run_test( const uint8_t*  data,
+            size_t          size_ )
   {
-    assert( !InitResult );
+#ifdef FT_FUZZER_FORCE_LOCAL_LIBRARY
+    FT_Library library_raw = nullptr;
+    FT_New_Library( const_cast<FT_Memory>(&gFTMemory), &library_raw );
+    assert( library_raw );
+    unique_ptr<std::remove_pointer<FT_Library>::type, decltype ( FT_Done_Library )*> library( library_raw, FT_Done_Library );
+    FT_Add_Default_Modules( library.get() );
+#endif
 
     if ( size_ < 1 )
       return 0;
@@ -193,7 +231,7 @@
     // more than a single font.
 
     // get number of faces
-    if ( FT_New_Memory_Face( library,
+    if ( FT_New_Memory_Face( library.get(),
                              files[0].data(),
                              (FT_Long)files[0].size(),
                              -1,
@@ -208,7 +246,7 @@
           face_index++ )
     {
       // get number of instances
-      if ( FT_New_Memory_Face( library,
+      if ( FT_New_Memory_Face( library.get(),
                                files[0].data(),
                                (FT_Long)files[0].size(),
                                -( face_index + 1 ),
@@ -222,7 +260,7 @@
             instance_index < num_instances + 1;
             instance_index++ )
       {
-        if ( FT_New_Memory_Face( library,
+        if ( FT_New_Memory_Face( library.get(),
                                  files[0].data(),
                                  (FT_Long)files[0].size(),
                                  ( instance_index << 16 ) + face_index,
@@ -306,5 +344,19 @@
     return 0;
   }
 
+  // the interface function to the libFuzzer library
+  extern "C" int
+  LLVMFuzzerTestOneInput( const uint8_t*  data,
+                          size_t          size_ )
+  {
+    int result = run_test( data, size_ );
+#ifdef FT_FUZZER_FORCE_LSAN_CHECK
+    if ( __lsan_do_recoverable_leak_check() ) {
+      exit(3);
+    }
+#endif
+    return result;
+  }
+
 
 // END
