forked from GitHub/gf-core
Haskell binding: free memory pool to avoid space leak when readPGF fails
This commit is contained in:
@@ -55,8 +55,10 @@ readPGF fpath =
|
|||||||
if ty == gu_type__GuErrno
|
if ty == gu_type__GuErrno
|
||||||
then do perrno <- (#peek GuExn, data.data) exn
|
then do perrno <- (#peek GuExn, data.data) exn
|
||||||
errno <- peek perrno
|
errno <- peek perrno
|
||||||
|
gu_pool_free pool
|
||||||
ioError (errnoToIOError "readPGF" (Errno errno) Nothing (Just fpath))
|
ioError (errnoToIOError "readPGF" (Errno errno) Nothing (Just fpath))
|
||||||
else throw (PGFError "The grammar cannot be loaded")
|
else do gu_pool_free pool
|
||||||
|
throw (PGFError "The grammar cannot be loaded")
|
||||||
else return pgf
|
else return pgf
|
||||||
master <- newForeignPtr gu_pool_finalizer pool
|
master <- newForeignPtr gu_pool_finalizer pool
|
||||||
return PGF {pgf = pgf, pgfMaster = master}
|
return PGF {pgf = pgf, pgfMaster = master}
|
||||||
|
|||||||
Reference in New Issue
Block a user