Skip to content

Commit 33b45f8

Browse files
committed
fix according to nh2's comment
1 parent 412dd0d commit 33b45f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Network/Socket/Types.hsc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,9 +1157,10 @@ unixPathMax = #const sizeof(((struct sockaddr_un *)NULL)->sun_path)
11571157
pokeSockAddr :: Ptr a -> SockAddr -> IO ()
11581158
pokeSockAddr p sa@(SockAddrUnix path) = do
11591159
let pathC = map castCharToCChar path
1160-
when (length pathC >= unixPathMax) $ error
1160+
len = length pathC
1161+
when (len >= unixPathMax) $ error
11611162
$ "pokeSockAddr: path is too long in SockAddrUnix " <> show path
1162-
<> ", length " <> show (length path) <> ", unixPathMax " <> show unixPathMax
1163+
<> ", length " <> show len <> ", unixPathMax " <> show unixPathMax
11631164
zeroMemory p $ fromIntegral $ sizeOfSockAddr sa
11641165
# if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
11651166
(#poke struct sockaddr_un, sun_len) p ((#const sizeof(struct sockaddr_un)) :: Word8)

0 commit comments

Comments
 (0)