diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,4 @@
+- 0.5.3.1: Fix leak of `FunPtr` when using `funCtx`.
 - 0.5.3.0: Recognize more standard library types.  See pull request #19.
 - 0.5.2.1: Convert `signed char` to `CSChar`.  See pull request #18.
 - 0.5.2.0: Make `bs-ptr` use `char` instead of `unsigned char`.  See
diff --git a/inline-c.cabal b/inline-c.cabal
--- a/inline-c.cabal
+++ b/inline-c.cabal
@@ -1,5 +1,5 @@
 name:                inline-c
-version:             0.5.3.0
+version:             0.5.3.1
 synopsis:            Write Haskell source files including C code inline. No FFI required.
 description:         See <https://github.com/fpco/inline-c/blob/master/README.md>.
 license:             MIT
diff --git a/src/Language/C/Inline/Context.hs b/src/Language/C/Inline/Context.hs
--- a/src/Language/C/Inline/Context.hs
+++ b/src/Language/C/Inline/Context.hs
@@ -55,7 +55,7 @@
 import qualified Data.Vector.Storable.Mutable as VM
 import           Data.Word (Word8, Word16, Word32, Word64)
 import           Foreign.C.Types
-import           Foreign.Ptr (Ptr, FunPtr)
+import           Foreign.Ptr (Ptr, FunPtr, freeHaskellFunPtr)
 import           Foreign.Storable (Storable)
 import qualified Language.Haskell.TH as TH
 import qualified Text.Parser.Token as Parser
@@ -314,7 +314,12 @@
       hsExp <- getHsVariable "funCtx" cId
       case hsTy of
         TH.AppT (TH.ConT n) hsTy' | n == ''FunPtr -> do
-          hsExp' <- [| \cont -> cont =<< $(mkFunPtr (return hsTy')) $(return hsExp) |]
+          hsExp' <- [| \cont -> do
+              funPtr <- $(mkFunPtr (return hsTy')) $(return hsExp)
+              x <- cont funPtr
+              freeHaskellFunPtr funPtr
+              return x
+            |]
           return (hsTy, hsExp')
         _ -> error "The `fun' marshaller captures function pointers only"
   }
