>From f2d1990ed0b5a2a8b48e9ed71ad821f7dd9a1fbd Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 31 Jul 2017 18:24:03 +0200 Subject: [PATCH] Do not underallocate the scratch space for ffi return types estimate-foreign-result-size should not assume the foreign type has zero size if all the checks fail as this may lead to segfaults in the generated code if eg. the type isn't defined yet. --- support.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/support.scm b/support.scm index fcf0b0c1..be399ead 100644 --- a/support.scm +++ b/support.scm @@ -1175,6 +1175,8 @@ ;;; Compute foreign result size: (define (estimate-foreign-result-size type) + (define (err t) + (quit "cannot compute size of foreign type `~S'" t) ) (follow-without-loop type (lambda (t next) @@ -1198,8 +1200,8 @@ (case (car t) [(ref nonnull-pointer pointer c-pointer nonnull-c-pointer function instance instance-ref nonnull-instance) (words->bytes 3) ] - [else 0] ) ] - [else 0] ) ) ) ) + [else (err t)] ) ] + [else (err t)] ) ) ) ) (lambda () (quit "foreign type `~S' refers to itself" type)) ) ) (define (estimate-foreign-result-location-size type) -- 2.11.0