aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-08-08 15:13:05 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-08-08 15:13:05 -0400
commitcfe84423c97eb2121138c2de5876c47782cd6dda (patch)
tree026afba62a3c412cee5fb4c40e4208f1e3038a3c /src/ir.cpp
parentbfa1d12fbad2031402fbafe51c3a0c481fe69351 (diff)
downloadzig-cfe84423c97eb2121138c2de5876c47782cd6dda.tar.gz
zig-cfe84423c97eb2121138c2de5876c47782cd6dda.zip
fix segfault with var args
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index f92434bb33..20a21bb5c3 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -15746,7 +15746,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
size_t impl_param_count = impl_fn_type_id->param_count;
if (call_instruction->is_async) {
IrInstruction *result = ir_analyze_async_call(ira, call_instruction, impl_fn, impl_fn->type_entry,
- nullptr, casted_args, call_param_count, casted_new_stack);
+ nullptr, casted_args, impl_param_count, casted_new_stack);
return ir_finish_anal(ira, result);
}
@@ -15756,7 +15756,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, &call_instruction->base,
impl_fn, nullptr, impl_param_count, casted_args, fn_inline,
- call_instruction->is_async, casted_new_stack, result_loc,
+ false, casted_new_stack, result_loc,
impl_fn_type_id->return_type);
parent_fn_entry->call_list.append(new_call_instruction);
@@ -15799,7 +15799,9 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
casted_args[next_arg_index] = casted_arg;
next_arg_index += 1;
}
- for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) {
+ size_t iter_count = (call_param_count < call_instruction->arg_count) ?
+ call_param_count : call_instruction->arg_count;
+ for (size_t call_i = 0; call_i < iter_count; call_i += 1) {
IrInstruction *old_arg = call_instruction->args[call_i]->child;
if (type_is_invalid(old_arg->value.type))
return ira->codegen->invalid_instruction;