packages feed

vty 5.38 → 5.39

raw patch · 6 files changed

+94/−2 lines, 6 filesdep ~basedep ~filepathnew-component:exe:vty-crash-fixnew-component:exe:vty-crash-test

Dependency ranges changed: base, filepath

Files

CHANGELOG.md view
@@ -1,4 +1,14 @@ +5.39+----++Package changes:+* Now builds with `mtl-2.3.*`.++Bug fixes:+* Fixed a long-standing issue where unused input on stdin could cause a+  memory error and a crash when Vty was being initialized. (#266)+ 5.38 ---- 
src/Graphics/Vty/Config.hs view
@@ -111,7 +111,7 @@ import Control.Applicative hiding (many)  import Control.Exception (catch, IOException, Exception(..), throwIO)-import Control.Monad (liftM, guard, void)+import Control.Monad (liftM, guard, void, when)  import qualified Data.ByteString as BS #if !(MIN_VERSION_base(4,8,0))@@ -132,6 +132,7 @@                         ) import System.Environment (lookupEnv) import System.FilePath ((</>), takeDirectory)+import System.IO (Handle, BufferMode(..), hReady, hSetBuffering, hGetChar, stdin) import System.Posix.IO (stdInput, stdOutput) import System.Posix.Types (Fd(..)) import Foreign.C.Types (CInt(..), CChar(..))@@ -293,6 +294,7 @@       Nothing -> throwIO VtyMissingTermEnvVar       Just t -> do         mcolorMode <- detectColorMode t+        flushInput stdin         return defaultConfig           { vmin               = Just 1           , mouseMode          = Just False@@ -486,3 +488,19 @@                    Nothing -> do                        appendFile configPath directive                        return ConfigurationModified++flushInput :: Handle -> IO ()+flushInput h = do+    hSetBuffering h NoBuffering+    whileM $ consume h++whileM :: (Monad m) => m Bool -> m ()+whileM act = do+    continue <- act+    when continue $ whileM act++consume :: Handle -> IO Bool+consume h = do+    avail <- hReady h+    when avail $ void $ hGetChar h+    return avail
src/Graphics/Vty/Input.hs view
@@ -154,6 +154,7 @@                             , vmin = Just _                             , vtime = Just _                             , .. } = do+     terminal <- Terminfo.setupTerm termName     let inputOverrides = [(s,e) | (t,s,e) <- inputMap, t == Nothing || t == Just termName]         activeInputMap = classifyMapForTerm termName terminal `mappend` inputOverrides
+ tools/CrashFix.hs view
@@ -0,0 +1,29 @@+module Main (main) where++import Control.Monad (when, void)+import Graphics.Vty+import System.IO++main :: IO ()+main = do+    flushInput stdin+    vty <- mkVty defaultConfig+    shutdown vty++flushInput :: Handle -> IO ()+flushInput h = do+    mode <- hGetBuffering h+    hSetBuffering h NoBuffering+    whileM $ consume h+    hSetBuffering h mode++whileM :: (Monad m) => m Bool -> m ()+whileM act = do+    continue <- act+    when continue $ whileM act++consume :: Handle -> IO Bool+consume h = do+    ava <- hReady h+    when ava $ void $ hGetChar h+    pure ava
+ tools/CrashTest.hs view
@@ -0,0 +1,8 @@+module Main (main) where++import Graphics.Vty++main :: IO ()+main = do+    vty <- mkVty defaultConfig+    shutdown vty
vty.cabal view
@@ -1,5 +1,5 @@ name:                vty-version:             5.38+version:             5.39 license:             BSD3 license-file:        LICENSE author:              AUTHORS@@ -109,6 +109,32 @@                        cbits/set_term_timing.c                        cbits/get_tty_erase.c                        cbits/mk_wcwidth.c++executable vty-crash-test+  main-is:             CrashTest.hs+  hs-source-dirs:      tools+  default-language:    Haskell2010+  ghc-options:         -threaded -Wall++  if !impl(ghc >= 8.0)+    build-depends:     semigroups >= 0.16++  build-depends:       base,+                       vty,+                       directory,+                       filepath++executable vty-crash-fix+  main-is:             CrashFix.hs+  hs-source-dirs:      tools+  default-language:    Haskell2010+  ghc-options:         -threaded -Wall++  if !impl(ghc >= 8.0)+    build-depends:     semigroups >= 0.16++  build-depends:       base,+                       vty  executable vty-build-width-table   main-is:             BuildWidthTable.hs