Skip to content

Commit

Permalink
Add stern warning for fromListN
Browse files Browse the repository at this point in the history
  • Loading branch information
Shimuuar committed May 1, 2021
1 parent fd98c93 commit a71c021
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion vector/src/Data/Vector/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,11 @@ fromList :: Vector v a => [a] -> v a
{-# INLINE fromList #-}
fromList = unstream . Bundle.fromList

-- | /O(n)/ Convert the first @n@ elements of a list to a vector
-- | /O(n)/ Convert the first @n@ elements of a list to a vector. It's
-- expected that supplied list will be exactly @n@ elements long. As
-- optimization this function allocates buffer for @n@ elements and
-- could be used to DoS by exhausting memory if attacker controls that
-- parameter.
--
-- @
-- fromListN n xs = 'fromList' ('take' n xs)
Expand Down
6 changes: 5 additions & 1 deletion vector/src/Data/Vector/Primitive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,11 @@ fromList :: Prim a => [a] -> Vector a
{-# INLINE fromList #-}
fromList = G.fromList

-- | /O(n)/ Convert the first @n@ elements of a list to a vector
-- | /O(n)/ Convert the first @n@ elements of a list to a vector. It's
-- expected that supplied list will be exactly @n@ elements long. As
-- optimization this function allocates buffer for @n@ elements and
-- could be used to DoS by exhausting memory if attacker controls that
-- parameter.
--
-- @
-- fromListN n xs = 'fromList' ('take' n xs)
Expand Down
6 changes: 5 additions & 1 deletion vector/src/Data/Vector/Storable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,11 @@ fromList :: Storable a => [a] -> Vector a
{-# INLINE fromList #-}
fromList = G.fromList

-- | /O(n)/ Convert the first @n@ elements of a list to a vector
-- | /O(n)/ Convert the first @n@ elements of a list to a vector. It's
-- expected that supplied list will be exactly @n@ elements long. As
-- optimization this function allocates buffer for @n@ elements and
-- could be used to DoS by exhausting memory if attacker controls that
-- parameter.
--
-- @
-- fromListN n xs = 'fromList' ('take' n xs)
Expand Down
6 changes: 5 additions & 1 deletion vector/src/Data/Vector/Unboxed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,11 @@ fromList :: Unbox a => [a] -> Vector a
{-# INLINE fromList #-}
fromList = G.fromList

-- | /O(n)/ Convert the first @n@ elements of a list to a vector
-- | /O(n)/ Convert the first @n@ elements of a list to a vector. It's
-- expected that supplied list will be exactly @n@ elements long. As
-- optimization this function allocates buffer for @n@ elements and
-- could be used to DoS by exhausting memory if attacker controls that
-- parameter.
--
-- @
-- fromListN n xs = 'fromList' ('take' n xs)
Expand Down

0 comments on commit a71c021

Please sign in to comment.