diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-06-16 15:18:48 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-06-16 15:18:49 -0400 |
commit | 9849403147b584ff160daeb4f13bf36adb2bab2e (patch) | |
tree | 71575819587edb945ad99e96637ed753e2b11324 /libraries | |
parent | 430137c45420153dafbd448b4d509f893fe675f4 (diff) | |
download | haskell-9849403147b584ff160daeb4f13bf36adb2bab2e.tar.gz |
base: Validate input in setNumCapabilities
Test Plan: validate
Reviewers: austin, hvr, erikd, simonmar
Subscribers: rwbarton, thomie
GHC Trac Issues: #13832
Differential Revision: https://phabricator.haskell.org/D3652
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/GHC/Conc/Sync.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libraries/base/GHC/Conc/Sync.hs b/libraries/base/GHC/Conc/Sync.hs index 78a0334617..44d34d8262 100644 --- a/libraries/base/GHC/Conc/Sync.hs +++ b/libraries/base/GHC/Conc/Sync.hs @@ -379,7 +379,9 @@ to avoid contention with other processes in the machine. @since 4.5.0.0 -} setNumCapabilities :: Int -> IO () -setNumCapabilities i = c_setNumCapabilities (fromIntegral i) +setNumCapabilities i + | i <= 0 = fail $ "setNumCapabilities: Capability count ("++show i++") must be positive" + | otherwise = c_setNumCapabilities (fromIntegral i) foreign import ccall safe "setNumCapabilities" c_setNumCapabilities :: CUInt -> IO () |