bos/text — pull request #50 by gridaphobe (2013-06-11 01:29:43+00:00)
Title: Fix a bug in `Data.Text.Fusion.mapAccumL`

If the parameter `f` maps from `Char`s that fit in a single `Word16` to `Char`s that require two `Word16`s, it is possible to write to an out-of-bounds index, as demonstrated by the following code:

```haskell
module Main where

import Data.Char
import qualified Data.Text as T

main = do
let f a c = (a, chr 65536)
print . T.mapAccumL f 0 . T.pack $ "aaaaa"
```

If you run this code with `-DASSERTS` you'll get an exception. The source of the issue is that in the inner loop of `Data.Text.Fusion.mapAccumL`, you determine the safety of writing into the array based on the `Char` passed to `f` instead of the one it returns.