harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit 5ae88660fdfb51b6cb3524c6d024b9059b3942e0
parent 521d77191bcf208a1dc8a6bb3387fe859faf43b3
Author: Sebastian LaVine <mail@smlavine.com>
Date:   Sat,  4 Jun 2022 12:43:57 -0400

Fix segfault on not enough params for variadic function call

As shown by this minimal test case:

fn foo(a: int, v: int...) void = void;

export fn main() void = {
	//foo(0); // << okay
	foo(); // harec segfaults
};

Signed-off-by: Sebastian LaVine <mail@smlavine.com>

Diffstat:
Msrc/check.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/check.c b/src/check.c @@ -1214,7 +1214,7 @@ check_expr_call(struct context *ctx, } } - if (param && fntype->func.variadism == VARIADISM_HARE) { + if (param && !param->next && fntype->func.variadism == VARIADISM_HARE) { // No variadic arguments, lower to empty slice arg = *next = xcalloc(1, sizeof(struct call_argument)); arg->value = xcalloc(1, sizeof(struct expression));