summaryrefslogtreecommitdiff
path: root/compiler/ghci/ByteCodeLink.lhs
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-08-01 13:00:14 +0000
committerIan Lynagh <igloo@earth.li>2009-08-01 13:00:14 +0000
commit6d92f8127b85a52a472b692c6fa40320432dd5a5 (patch)
tree7bf498a8651b4c8e8dd0897bdf0d9eb387943205 /compiler/ghci/ByteCodeLink.lhs
parent00d1ec1fb730671f159add194e45fe266b3d86aa (diff)
downloadhaskell-6d92f8127b85a52a472b692c6fa40320432dd5a5.tar.gz
Fix the 64k insns overflow check in ghci, and add more checks
Diffstat (limited to 'compiler/ghci/ByteCodeLink.lhs')
-rw-r--r--compiler/ghci/ByteCodeLink.lhs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/ghci/ByteCodeLink.lhs b/compiler/ghci/ByteCodeLink.lhs
index f0ab8cf2e5..7d94d2c72f 100644
--- a/compiler/ghci/ByteCodeLink.lhs
+++ b/compiler/ghci/ByteCodeLink.lhs
@@ -119,15 +119,19 @@ linkBCO' ie ce (UnlinkedBCO nm arity insns_barr bitmap literalsSS ptrsSS)
let n_literals = sizeSS literalsSS
n_ptrs = sizeSS ptrsSS
- ptrs_arr <- mkPtrsArray ie ce n_ptrs ptrs
+ ptrs_arr <- if n_ptrs > 65535
+ then panic "linkBCO: >= 64k ptrs"
+ else mkPtrsArray ie ce (fromIntegral n_ptrs) ptrs
let
!ptrs_parr = case ptrs_arr of Array _lo _hi _n parr -> parr
- litRange = if n_literals > 0 then (0, n_literals-1)
- else (1, 0)
+ litRange
+ | n_literals > 65535 = panic "linkBCO: >= 64k literals"
+ | n_literals > 0 = (0, fromIntegral n_literals - 1)
+ | otherwise = (1, 0)
+ literals_arr :: UArray Word16 Word
literals_arr = listArray litRange linked_literals
- :: UArray Word16 Word
!literals_barr = case literals_arr of UArray _lo _hi _n barr -> barr
!(I# arity#) = arity