Skip to content

Commit 9281d67

Browse files
committed
unfoildrN{,M} now uses Unknown allocation strategy
Before functions allocated array of maximum size immediately. This is problem in case when attacker controls size parameter and could lead to DoS. It's also problem when size parameter is just a limit vector is usually shorter. Usual doubling strategy looks more conservative in this function. Fixes #301
1 parent 2ec9d87 commit 9281d67

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vector/src/Data/Vector/Fusion/Bundle/Monadic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ unfoldrN n f = unfoldrNM n (return . f)
664664
-- | Unfold at most @n@ elements with a monadic function.
665665
unfoldrNM :: Monad m => Int -> (s -> m (Maybe (a, s))) -> s -> Bundle m u a
666666
{-# INLINE_FUSED unfoldrNM #-}
667-
unfoldrNM n f s = fromStream (S.unfoldrNM n f s) (Max (delay_inline max n 0))
667+
unfoldrNM n f s = fromStream (S.unfoldrNM n f s) Unknown
668668

669669
-- | Unfold exactly @n@ elements
670670
--

0 commit comments

Comments
 (0)