Cast NULL pointer to nil in return in ffi.

This commit is contained in:
Calvin Rose 2022-06-18 16:53:01 -05:00
parent 1a1dd39367
commit 20511cf608
1 changed files with 4 additions and 2 deletions

View File

@ -491,8 +491,10 @@ static Janet janet_ffi_read_one(const uint8_t *from, JanetFFIType type, int recu
return janet_wrap_number(((double *)(from))[0]);
case JANET_FFI_TYPE_FLOAT:
return janet_wrap_number(((float *)(from))[0]);
case JANET_FFI_TYPE_PTR:
return janet_wrap_pointer(((void **)(from))[0]);
case JANET_FFI_TYPE_PTR: {
void *ptr = ((void **)(from))[0];
return (NULL == ptr) ? janet_wrap_nil() : janet_wrap_pointer(ptr);
}
case JANET_FFI_TYPE_BOOL:
return janet_wrap_boolean(((bool *)(from))[0]);
case JANET_FFI_TYPE_INT8: