better bounds check for table.get and table.set
This commit is contained in:
1 parent
4e9105717b
commit
71d332e3dc
2 files changed
+3
-3
No files matched your search
@@ -982,7 +982,7 @@ eval budget store FunctionInstance { funcType, moduleInstance, code = Function {
|
||||
RF fnRef -> fnRef
|
||||
v -> error "Impossible due to validation"
|
||||
els <- readIORef items
|
||||
if dst > MVector.length els
|
||||
if dst >= MVector.length els
|
||||
then return Trap
|
||||
else do
|
||||
MVector.unsafeWrite els dst (fromIntegral <$> val)
|
||||
@@ -992,7 +992,7 @@ eval budget store FunctionInstance { funcType, moduleInstance, code = Function {
|
||||
let TableInstance { t = TableType _ et, items } = tableInstances store ! tableAddr
|
||||
let dst = fromIntegral offset
|
||||
els <- readIORef items
|
||||
if dst > MVector.length els
|
||||
if dst >= MVector.length els
|
||||
then return Trap
|
||||
else do
|
||||
v <- MVector.unsafeRead els dst
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ main = do
|
||||
files <-
|
||||
filter (not . List.isPrefixOf "simd") . filter (List.isSuffixOf ".wast")
|
||||
<$> Directory.listDirectory "tests/spec"
|
||||
let files = ["table_get.wast"]
|
||||
-- let files = ["table_get.wast"]
|
||||
scriptTestCases <- (`mapM` files) $ \file -> do
|
||||
test <- LBS.readFile ("tests/spec/" ++ file)
|
||||
return $ testCase file $ do
|
||||
|
||||
Reference in new issue
Block a user