summaryrefslogtreecommitdiff
path: root/src/Erebos
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-01-06 19:08:40 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-01-09 21:42:24 +0100
commit1f6eb330e9fd9f0004dec4783496d36520dbd2a3 (patch)
treef6b5d75704078532ddbc4d8507917a7634071dcb /src/Erebos
parente057476beb4eb7e5194665536c6f7073aa6f790f (diff)
Network: check and free interface list in joinMulticastrelease-0.1
Diffstat (limited to 'src/Erebos')
-rw-r--r--src/Erebos/Network.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Erebos/Network.hs b/src/Erebos/Network.hs
index e9a4182..d8e868a 100644
--- a/src/Erebos/Network.hs
+++ b/src/Erebos/Network.hs
@@ -984,9 +984,15 @@ joinMulticast sock =
withFdSocket sock $ \fd ->
alloca $ \pcount -> do
ptr <- cJoinMulticast fd pcount
- count <- fromIntegral <$> peek pcount
- forM [ 0 .. count - 1 ] $ \i ->
- peekElemOff ptr i
+ if ptr == nullPtr
+ then do
+ return []
+ else do
+ count <- fromIntegral <$> peek pcount
+ res <- forM [ 0 .. count - 1 ] $ \i ->
+ peekElemOff ptr i
+ cFree ptr
+ return res
getServerAddresses :: Server -> IO [ SockAddr ]
getServerAddresses Server {..} = do