packages feed

hslua 0.3.9 → 0.3.10

raw patch · 2 files changed

+5/−2 lines, 2 files

Files

hslua.cabal view
@@ -1,5 +1,5 @@ Name:                   hslua-Version:                0.3.9+Version:                0.3.10 Stability:              beta Cabal-version:          >= 1.8 License:                MIT
src/Scripting/Lua.hs view
@@ -487,7 +487,10 @@ 
 -- | See @lua_tostring@ in Lua Reference Manual.
 tostring :: LuaState -> Int -> IO String
-tostring l n = c_lua_tolstring l (fromIntegral n) nullPtr >>= peekCString
+tostring l n = alloca $ \lenPtr -> do
+    cstr <- c_lua_tolstring l (fromIntegral n) lenPtr
+    len <- F.peek lenPtr
+    peekCStringLen (cstr, fromIntegral len)
 
 -- | See @lua_tothread@ in Lua Reference Manual.
 tothread :: LuaState -> Int -> IO LuaState