~sircmpwn/hare-dev

harec: Fix segfault on not enough params for variadic function call v1 PROPOSED

Sebastian LaVine: 1
 Fix segfault on not enough params for variadic function call

 1 files changed, 1 insertions(+), 1 deletions(-)
#773869 alpine.yml success
#773870 freebsd.yml failed
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/hare-dev/patches/32748/mbox | git am -3
Learn more about email & git

[PATCH harec] Fix segfault on not enough params for variadic function call Export this patch

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>
---
 src/check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/check.c b/src/check.c
index 558187f..f5980c3 100644
--- a/src/check.c
+++ b/src/check.c
@@ -1211,7 +1211,7 @@ check_expr_call(struct context *ctx,
		}
	}

	if (param && fntype->func.variadism == VARIADISM_HARE) {
	if (param && param->type->array.members && 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));
-- 
2.36.1
harec/patches: FAILED in 56s

[Fix segfault on not enough params for variadic function call][0] from [Sebastian LaVine][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/32748
[1]: mailto:mail@smlavine.com

✓ #773869 SUCCESS harec/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/773869
✗ #773870 FAILED  harec/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/773870