File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,8 @@ decodeWithBasePosix ba = B.useAsCStringLen ba $ \fp -> peekFilePathPosix fp
153
153
-- | Wrapper around 'useAsCString', checking the encoded 'FilePath' for internal NUL octets as these are
154
154
-- disallowed in POSIX filepaths. See https://gitlab.haskell.org/ghc/ghc/-/issues/13660
155
155
useAsCStringSafe :: RawFilePath -> (CString -> IO a ) -> IO a
156
- useAsCStringSafe path f = useAsCStringLen path $ \ (ptr, len) -> do
156
+ useAsCStringSafe path f = useAsCString path $ \ ptr -> do
157
+ let len = B. length path
157
158
clen <- c_strlen ptr
158
159
if clen == fromIntegral len
159
160
then f ptr
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ import Data.ByteString.Internal (c_strlen)
45
45
import Control.Monad
46
46
import Control.Exception
47
47
import System.OsPath.Posix as PS
48
- import System.OsPath.Data.ByteString.Short
48
+ import System.OsPath.Data.ByteString.Short as BSS
49
49
import Prelude hiding (FilePath )
50
50
import System.OsString.Internal.Types (PosixString (.. ), pattern PS )
51
51
import GHC.IO.Exception
@@ -147,7 +147,8 @@ _toStr = fmap PS.toChar . PS.unpack
147
147
-- | Wrapper around 'useAsCString', checking the encoded 'FilePath' for internal NUL octets as these are
148
148
-- disallowed in POSIX filepaths. See https://gitlab.haskell.org/ghc/ghc/-/issues/13660
149
149
useAsCStringSafe :: PosixPath -> (CString -> IO a ) -> IO a
150
- useAsCStringSafe pp@ (PS path) f = useAsCStringLen path $ \ (ptr, len) -> do
150
+ useAsCStringSafe pp@ (PS path) f = useAsCString path $ \ ptr -> do
151
+ let len = BSS. length path
151
152
clen <- c_strlen ptr
152
153
if clen == fromIntegral len
153
154
then f ptr
You can’t perform that action at this time.
0 commit comments