Made decoding array lookup safe
Ignore-this: 346535974ae363daf4ade7e22ed48ad7 darcs-hash:20090226144653-a4fee-42808f15a3bab3fa1712ab12d8b0cfb54ff96aad
This commit is contained in:
parent
6eb2d51ee2
commit
3270e03da1
@ -76,7 +76,11 @@ decodeWithArray2 :: ByteSource m => UArray (Word8,Word8) Int -> m Char
|
|||||||
decodeWithArray2 arr = do
|
decodeWithArray2 arr = do
|
||||||
w1 <- fetchWord8
|
w1 <- fetchWord8
|
||||||
w2 <- fetchWord8
|
w2 <- fetchWord8
|
||||||
let res = arr!(w1,w2)
|
if inRange (bounds arr) (w1,w2)
|
||||||
if res < 0
|
then (do
|
||||||
then throwException $ IllegalCharacter w1
|
let res = arr!(w1,w2)
|
||||||
else return $ chr res
|
if res < 0
|
||||||
|
then throwException $ IllegalCharacter w1
|
||||||
|
else return $ chr res
|
||||||
|
)
|
||||||
|
else throwException $ IllegalCharacter w1
|
||||||
Loading…
Reference in New Issue
Block a user