From 4f0fed4698f109306ff6b102aec1bc2eb2a6f06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Fri, 21 Jun 2024 21:43:43 +0200 Subject: [PATCH] ffi: fix size-of-foreign-type when called on structore with no slots Fixes #752. --- src/lsp/ffi.lsp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lsp/ffi.lsp b/src/lsp/ffi.lsp index 1453266af..bb4fd1f09 100644 --- a/src/lsp/ffi.lsp +++ b/src/lsp/ffi.lsp @@ -71,14 +71,15 @@ does not include any Lisp storage overhead." ((atom type) (error "~A is not a valid foreign type identifier" name)) ((eq (setf name (first type)) :struct) - (setf size (slot-position type nil) - align (apply #'max (mapcar #'(lambda (field) - (multiple-value-bind (field-size field-align) - (size-of-foreign-type (second field)) - (declare (ignore field-size)) - field-align)) - (rest type)))) - (%align-data size align)) + (setf size (slot-position type nil)) + (when (rest type) + (setf align (apply #'max (mapcar #'(lambda (field) + (multiple-value-bind (field-size field-align) + (size-of-foreign-type (second field)) + (declare (ignore field-size)) + field-align)) + (rest type)))) + (%align-data size align))) ((eq name :array) (unless (and (setf size (third type)) (realp size)) (error "Incomplete foreign type: ~S" type))