File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 7
7
8
8
module Network.Socket.Info where
9
9
10
+ import Control.Exception (mask , onException )
10
11
import Data.List.NonEmpty (NonEmpty (.. ))
11
12
import qualified Data.List.NonEmpty as NE
12
13
import Foreign.Marshal.Alloc (alloca , allocaBytes )
@@ -274,11 +275,12 @@ getAddrInfoNE hints node service = alloc getaddrinfo
274
275
maybeWith with filteredHints $ \ c_hints ->
275
276
alloca $ \ ptr_ptr_addrs ->
276
277
body c_node c_service c_hints ptr_ptr_addrs
277
- getaddrinfo c_node c_service c_hints ptr_ptr_addrs = do
278
+ getaddrinfo c_node c_service c_hints ptr_ptr_addrs = mask $ \ release -> do
278
279
ret <- c_getaddrinfo c_node c_service c_hints ptr_ptr_addrs
279
280
if ret == 0 then do
280
281
ptr_addrs <- peek ptr_ptr_addrs
281
- ais <- followAddrInfo ptr_addrs
282
+ ais <- release (followAddrInfo ptr_addrs) `onException` c_freeaddrinfo ptr_addrs
283
+ c_freeaddrinfo ptr_addrs
282
284
return ais
283
285
else do
284
286
err <- gai_strerror ret
You can’t perform that action at this time.
0 commit comments