diff --git a/CHANGELOG.md b/CHANGELOG.md index 462474b..11068eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This change ## [Unreleased] ### Fixed +- Deserializing nullpointers as functions threw an exception - Upcall stubs with non-primitive arguments failed to compile - Upcall stubs had incorrect types diff --git a/src/clj/coffi/ffi.clj b/src/clj/coffi/ffi.clj index ed93bfc..c6558a0 100644 --- a/src/clj/coffi/ffi.clj +++ b/src/clj/coffi/ffi.clj @@ -367,13 +367,14 @@ (defmethod mem/deserialize* ::fn [addr [_fn arg-types ret-type & {:keys [raw-fn?]}]] - (-> addr - (downcall-handle - (method-type arg-types ret-type) - (function-descriptor arg-types ret-type)) - (downcall-fn arg-types ret-type) - (cond-> - (not raw-fn?) (make-serde-wrapper arg-types ret-type)))) + (when-not (mem/null? addr) + (-> addr + (downcall-handle + (method-type arg-types ret-type) + (function-descriptor arg-types ret-type)) + (downcall-fn arg-types ret-type) + (cond-> + (not raw-fn?) (make-serde-wrapper arg-types ret-type))))) ;;; Static memory access