@@ -284,9 +284,11 @@ findBound :: S.ByteString -> S.ByteString -> Bound
284findBound b bs = handleBreak $ Search.breakOn b bs
284findBound b bs = handleBreak $ Search.breakOn b bs
286 handleBreak (h, t)
286 handleBreak (h, t)
287− | S.null t = go [S.length bs - S.length b..S.length bs - 1]
287+ | S.null t = go [lowBound..S.length bs - 1]
288 | otherwise = FoundBound h $ S.drop (S.length b) t
288 | otherwise = FoundBound h $ S.drop (S.length b) t
290+ lowBound = max 0 $ S.length bs - S.length b
290 go [] = NoBound
292 go [] = NoBound
291 go (i:is)
293 go (i:is)
292 | mismatch [0..S.length b - 1] [i..S.length bs - 1] = go is
294 | mismatch [0..S.length b - 1] [i..S.length bs - 1] = go is