Made decoding array lookup safe

Ignore-this: 346535974ae363daf4ade7e22ed48ad7

darcs-hash:20090226144653-a4fee-42808f15a3bab3fa1712ab12d8b0cfb54ff96aad
This commit is contained in:
Henning Guenther 2009-02-26 06:46:53 -08:00
parent 6eb2d51ee2
commit 3270e03da1

View File

@ -76,7 +76,11 @@ decodeWithArray2 :: ByteSource m => UArray (Word8,Word8) Int -> m Char
decodeWithArray2 arr = do
w1 <- fetchWord8
w2 <- fetchWord8
let res = arr!(w1,w2)
if res < 0
then throwException $ IllegalCharacter w1
else return $ chr res
if inRange (bounds arr) (w1,w2)
then (do
let res = arr!(w1,w2)
if res < 0
then throwException $ IllegalCharacter w1
else return $ chr res
)
else throwException $ IllegalCharacter w1