Skip to content

Commit d80679d

Browse files
authored
Reject excess ctypes paramflags arguments (#9621)
For calls without keyword arguments, reject extra positional arguments instead of silently dropping them before the foreign call. Assisted-by: OpenAI Codex:model version not exposed
1 parent e288ec6 commit d80679d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎crates/vm/src/stdlib/_ctypes/function.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,14 @@ fn build_callargs_with_paramflags(
14301430
}
14311431
}
14321432

1433+
if !arg_types.is_empty() && args.kwargs.is_empty() && caller_arg_idx < args.args.len() {
1434+
return Err(vm.new_type_error(format!(
1435+
"call takes exactly {} arguments ({} given)",
1436+
caller_arg_idx,
1437+
args.args.len(),
1438+
)));
1439+
}
1440+
14331441
Ok((arguments, out_buffers))
14341442
}
14351443

0 commit comments

Comments
 (0)