Fix segfault on chibi scheme when passing null pointers

This commit is contained in:
2025-07-08 08:28:41 +03:00
parent 6631c08bd9
commit 4c89153790
4 changed files with 21 additions and 14 deletions
+6
View File
@@ -69,6 +69,12 @@
(let ((c-function (dlsym shared-object c-name))
(maybe-dlerror (dlerror)))
(lambda arguments
(display "NAME: ")
(display c-name)
(newline)
(display "ARGS: ")
(write arguments)
(newline)
(let* ((return-pointer
(internal-ffi-call (length argument-types)
(type->libffi-type-number return-type)
+4 -1
View File
@@ -109,7 +109,9 @@
double vals18[nargs];
void* vals20[nargs];
printf(\"nargs: %i\\n\", nargs);
for(int i = 0; i < nargs; i++) {
printf(\"i: %i\\n\", i);
void* arg = NULL;
switch(atypes[i]) {
case 1:
@@ -202,10 +204,11 @@
case 19:
c_atypes[i] = &ffi_type_void;
arg = NULL;
c_avalues[i] = NULL;
break;
case 20:
c_atypes[i] = &ffi_type_pointer;
if(avalues[i] != NULL) {
if(sexp_cpointerp(avalues[i])) {
vals20[i] = sexp_cpointer_value(avalues[i]);
} else {
vals20[i] = NULL;