Skip to content
Browse files

fix issue in copyStringVec

the 'len' must be Int32, or else we segfault on 64-bit linux.
  • Loading branch information...
1 parent 65e40dc commit bbf58b347a9ab324936e15a43f7433feb4e7d73b @pheaver pheaver committed Aug 16, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/Zookeeper.hsc
View
6 src/Zookeeper.hsc
@@ -1,4 +1,4 @@
-
+{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
@@ -349,9 +349,9 @@ copyStat stat = do
copyStringVec :: Ptr b -> IO [String]
copyStringVec bufPtr = do
- len <- (#peek struct String_vector, count) bufPtr
+ len::Int32 <- (#peek struct String_vector, count) bufPtr
vec <- (#peek struct String_vector, data ) bufPtr
- mapM (peekCString <=< peek . plusPtr vec . (* #size char*)) [0..len-1]
+ mapM (peekCString <=< peek . plusPtr vec . (* #size char*) . fromIntegral) [0..len-1]
withMaybeCStringLen :: Maybe ByteString -> (CStringLen -> IO a) -> IO a
withMaybeCStringLen Nothing func = func (nullPtr, -1)

0 comments on commit bbf58b3

Please sign in to comment.
Something went wrong with that request. Please try again.