forgot releasing a stable pointer

This commit is contained in:
krangelov
2021-08-12 14:45:05 +02:00
parent 7e35db47a6
commit 352dedc26f

View File

@@ -287,6 +287,7 @@ readExpr str =
if c_expr == castPtrToStablePtr nullPtr if c_expr == castPtrToStablePtr nullPtr
then return Nothing then return Nothing
else do expr <- deRefStablePtr c_expr else do expr <- deRefStablePtr c_expr
freeStablePtr c_expr
return (Just expr) return (Just expr)
-- | parses a 'String' as a type -- | parses a 'String' as a type
@@ -295,11 +296,12 @@ readType str =
unsafePerformIO $ unsafePerformIO $
withText str $ \c_str -> withText str $ \c_str ->
bracket mkUnmarshaller freeUnmarshaller $ \u -> do bracket mkUnmarshaller freeUnmarshaller $ \u -> do
c_type <- pgf_read_type c_str u c_ty <- pgf_read_type c_str u
if c_type == castPtrToStablePtr nullPtr if c_ty == castPtrToStablePtr nullPtr
then return Nothing then return Nothing
else do tp <- deRefStablePtr c_type else do ty <- deRefStablePtr c_ty
return (Just tp) freeStablePtr c_ty
return (Just ty)
----------------------------------------------------------------------- -----------------------------------------------------------------------
-- Exceptions -- Exceptions