From 64e2e1456247205431d17eb812cec18a495f03de Mon Sep 17 00:00:00 2001 From: Ilya Rezvov Date: Wed, 15 Jan 2025 17:26:16 -0700 Subject: [PATCH] validate table type for call_indirect --- src/Language/Wasm/Validate.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Language/Wasm/Validate.hs b/src/Language/Wasm/Validate.hs index ae9256f..7d35645 100644 --- a/src/Language/Wasm/Validate.hs +++ b/src/Language/Wasm/Validate.hs @@ -278,6 +278,8 @@ getInstrType _ (CallIndirect tableIdx sign) = do if length tables <= fromIntegral tableIdx then throwError (TableIndexOutOfRange tableIdx) else do + let TableType _ elemType = tables !! fromIntegral tableIdx + when (elemType /= FuncRef) $ throwError (RefTypeMismatch FuncRef ExternRef) Arrow from to <- maybeToEither TypeIndexOutOfRange $ asArrow <$> types !? sign return $ (from ++ [Val I32]) ==> to getInstrType _ Drop = do