Repository : ssh://darcs.haskell.org//srv/darcs/packages/unix On branch : master
http://hackage.haskell.org/trac/ghc/changeset/76dad7afeaef33576940b64a7b3be91d05434df5 >--------------------------------------------------------------- commit 76dad7afeaef33576940b64a7b3be91d05434df5 Author: Ian Lynagh <[email protected]> Date: Sat Dec 1 22:31:48 2012 +0000 Fix putenv; trac #7342 We were freeing the string, but the string becomes part of the environment. >--------------------------------------------------------------- System/Posix/Env.hsc | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/System/Posix/Env.hsc b/System/Posix/Env.hsc index ecc6281..f7878b8 100644 --- a/System/Posix/Env.hsc +++ b/System/Posix/Env.hsc @@ -38,7 +38,7 @@ import Foreign.Ptr import Foreign.Storable import Control.Monad import Data.Maybe (fromMaybe) -import System.Posix.Internals (withFilePath, peekFilePath) +import System.Posix.Internals -- |'getEnv' looks up a variable in the environment. @@ -124,8 +124,11 @@ unsetEnv name = putEnv (name ++ "=") -- and is equivalent to @setEnv(key,value,True{-overwrite-})@. putEnv :: String -> IO () -putEnv keyvalue = withFilePath keyvalue $ \s -> - throwErrnoIfMinus1_ "putenv" (c_putenv s) +putEnv keyvalue = do s <- newFilePath keyvalue + -- Do not free `s` after calling putenv. + -- According to SUSv2, the string passed to putenv + -- becomes part of the enviroment. #7342 + throwErrnoIfMinus1_ "putenv" (c_putenv s) foreign import ccall unsafe "putenv" c_putenv :: CString -> IO CInt _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
