fix(vm): validate arg count before OpCall#904
Merged
antonmedv merged 1 commit intoexpr-lang:masterfrom Jan 15, 2026
Merged
Conversation
Prevent index out of bounds panic when calling a function with more
arguments than it accepts. The VM now validates argument count before
attempting to access parameter types. Includes a regression test.
This issue was discovered by clusterfuzz with the expression:
$env(''matches' '? :now().UTC(g).d)//
Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
12e4dda to
ba973ef
Compare
antonmedv
approved these changes
Jan 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
See OSS-Fuzz finding #903. The expression
$env(''matches' '? :now().UTC(g).d)//caused:The expression bypasses compile-time type checking due to
$env(...)being treated as an unknown type. Also the ternary operator deferring evaluation. Then at runtimeUTC()is called with an argument - even though it takes none. When theOpCallhandler accessesfnType.In(0)without checking its length, an index out of bounds panic happens, although recovered by the VM.Changes
Added argument count validation in VM before attempting to call functions. Including a regression test.
Further comments
Functions that return no values are already caught by the checker at compile time, so the
out[0]access afterfn.Call()remains safe.Regression from #889.
Nice edge case catched by the fuzzer.