[Git][ghc/ghc][master] Fix off by one error in seekBinNoExpand and seekBin
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Thu Apr 4 18:49:19 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
28009fbc by Matthew Pickering at 2024-04-04T14:48:46-04:00
Fix off by one error in seekBinNoExpand and seekBin
- - - - -
1 changed file:
- compiler/GHC/Utils/Binary.hs
Changes:
=====================================
compiler/GHC/Utils/Binary.hs
=====================================
@@ -243,15 +243,18 @@ tellBin (BinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix)
seekBin :: BinHandle -> Bin a -> IO ()
seekBin h@(BinMem _ ix_r sz_r _) (BinPtr !p) = do
sz <- readFastMutInt sz_r
- if (p >= sz)
+ if (p > sz)
then do expandBin h p; writeFastMutInt ix_r p
else writeFastMutInt ix_r p
--- | SeekBin but without calling expandBin
+-- | 'seekBinNoExpand' moves the index pointer to the location pointed to
+-- by 'Bin a'.
+-- This operation may 'panic', if the pointer location is out of bounds of the
+-- buffer of 'BinHandle'.
seekBinNoExpand :: BinHandle -> Bin a -> IO ()
seekBinNoExpand (BinMem _ ix_r sz_r _) (BinPtr !p) = do
sz <- readFastMutInt sz_r
- if (p >= sz)
+ if (p > sz)
then panic "seekBinNoExpand: seek out of range"
else writeFastMutInt ix_r p
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28009fbc26e4aca7a3b05cedb60c5c9baa31223d
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28009fbc26e4aca7a3b05cedb60c5c9baa31223d
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240404/b093ceab/attachment-0001.html>
More information about the ghc-commits
mailing list